Welcome, Guest
Username Password: Remember me
Please ask here your questions related to DAX and PowerPivot for Excel or PowerPivot for SharePoint. To post your question or reply you need to login first!
  • Page:
  • 1

TOPIC: DAX Conditional Statements...

DAX Conditional Statements... 1 year, 3 months ago #368

  • san463
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
I am a newbie to DAX queries. I need suggestions in re writing MDX Case statements in DAX format. I can use IF conditions but there are CASE and ELSE mdx statements which I am not sure how I should write in DAX format. Can anybody give me a hint.
For example I have the following case statement:
CASE
WHEN (([Measures].[Daily Rolling Run Rate] * 10 ) + [Measures].[Marketing Campaigns By BG] + [Measures].[ESD @ Retail Channel Monthly - Hidden])<100
THEN 100
ELSE (([Measures].[Daily Rolling Run Rate] * 10 ) + [Measures].[Marketing Campaigns By BG] + [Measures].[ESD @ Retail Channel Monthly - Hidden])
END
In order to convert the above, should I use IF? When should I use IIF and ELSE in DAX.

Thank you,

Sandeep

Re: DAX Conditional Statements... 1 year, 3 months ago #370

Suggestion:
Try creating a measure for the
([Measures].[Daily Rolling Run Rate] * 10 ) + [Measures].[Marketing Campaigns By BG] + [Measures].[ESD @ Retail Channel Monthly - Hidden]
And then create a new measure as follows:
=IF ( Measure.created < 100,
100,
Measure.created)

As easy as it sounds.

Hope this helps

Re: DAX Conditional Statements... 1 year, 3 months ago #371

  • san463
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
Thank you very much for the suggestion...I have one more question in regards to the following functions...These are the functions in MDX...I cannot seem to find the equivalent DAX functions...Can you suggest me what functions are equivalent to these..
LASTPERIODS,LinkMember,ClosingPeriod,STRTOMEMBER,ascendants. Thanks in advance.

Re: DAX Conditional Statements... 1 year, 3 months ago #372

I do not know that much about MDX, could you please translate the mdx syntax into simple English so I can then try to translate that to DAX?
Also, what Powerpivot version are you using? some functions from the new version of PP are not supported in previous versions (SQL 2008 R2).
Last Edit: 1 year, 3 months ago by miguel.escobar.

Re: DAX Conditional Statements... 1 year, 1 month ago #416

  • san463
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
This is a simple calculation of Date Difference, yet the scenario itself is complex.

Scenario: I have 3 tables, one fact and two dimensions. Below please find the tables with sample data:

Fact Table

ProductSK DateSK

ABC 01/01/2011
XYZ 01/02/2011
DEF 09/09/2010


Product Dimension Table

ProductSK PKPN

ABC RTY
ABC UOP
XYZ WER
XYZ WQS
DEF NMB
DEF SDF

DATE Dimension is a regular calendar date dimension as in your book.

Few words about the Scenario: The fact table relates to products dimension via ProductSK. The fact table relates to DATE dimension via Datesk. There is no relationship between Product Dimension and Date Dimension. What I am seeking here is to get date difference between first date of each pkpn to todays date. For Example, For PKPN “RTY” the first date is 01/01/2011, then the date difference is TODAY() or NOW() minus the first date (which would be 01/01/2011). Also, I need to mention that for each ProductSK there will be Many PKPNs and the combination of ProductSK and PKPN will give us the correct dates.

Solution: I tried Many solutions but to no satisfaction. I think I am doing almost right but, I am not getting the exact answers. Javier Guillen provided me with this wonderful example of LOOKUPVALUE function in DAX in order to get minimum date. Also with the Alberto example, Counting Active Days (sqlblog.com/blogs/alberto_ferrari/archiv...ing-active-days.aspx) I was able to get some of the information but not correct one. I have been working on this for couple of days but I don’t see the soil yet. Any help is appreciated . Below is the solution I arrived yet.

=SUMX (
‘FactTable’,
CALCULATE (
COUNTROWS (Date),
Date[Date] >= EARLIER (LOOKUPVALUE(DATE(DATE),DATE(DATESK),MIN(FACTTABE[DATE]))),
Date[Date] <= TODAY()
)
)

Thanks
  • Page:
  • 1
Moderators: VidasMatelis, dgosbell
Time to create page: 0.21 seconds
 

Pyramid+PowerPivot