locked
How can I check level for what specific calculation is done in DAX? RRS feed

  • Question

  • I created calculation that checks if cell is calculated for date dimension lovest level Date[Date], or if that calculation is for level above. I used following code:

    =IF(IsError(VALUES('Date'[Date])),"Calc for higher level", "Calc for day level")
    Is that correct way to do? Is there any other way to do the same thing? Can I somehow return the string that will tell me what level my cell calculation is at?

    Thank you,

    Vidas Matelis
    http://www.ssas-info.com http://powerpivot-info.com
    Monday, November 30, 2009 1:03 AM

Answers

  • Hi, Vidas,

    After consulted with Marius, the best practice is to avoid IsError whenever possible. To achieve the same result, you can use the following formula instead:

    =If( CountRows( VALUES(DimDate[FullDateAlternateKey])) = 1, "Calc for day Level", "Calc for higher Level")

    On the current version of the production, there is no way to further distinguish on which higher level the calculation is performed. This might change in future release.

    Thanks,
    Lisa
    • Marked as answer by Vidas Matelis Tuesday, December 1, 2009 1:48 AM
    Monday, November 30, 2009 10:03 PM

All replies

  • Hi, Vidas,

    After consulted with Marius, the best practice is to avoid IsError whenever possible. To achieve the same result, you can use the following formula instead:

    =If( CountRows( VALUES(DimDate[FullDateAlternateKey])) = 1, "Calc for day Level", "Calc for higher Level")

    On the current version of the production, there is no way to further distinguish on which higher level the calculation is performed. This might change in future release.

    Thanks,
    Lisa
    • Marked as answer by Vidas Matelis Tuesday, December 1, 2009 1:48 AM
    Monday, November 30, 2009 10:03 PM
  • Lisa,

    Thank you and thanks Marius! Your solution clearly is more elegant.

    Vidas Matelis

    http://www.ssas-info.com
    http://powerpivot-info.com
    Tuesday, December 1, 2009 2:40 AM