Forum Discussion
Hard Coded Values in DAX Measures
Hi All,
Quick question around hard coded numbers into measures - If you're creating a formula like the following:
Divide([Measure A],[Measure B]) -1
Is there a way outside of SWITCH(TRUE,ISBLANK([Measure A],BLANK(),Divide([Measure A],[Measure B]) -1 to prevent all records appearing, even if they don't appear in the Row context?
Standard Star Scheme approach
Thanks,
Freece4802 To prevent all records from appearing when either [Measure A] or [Measure B] is blank, you can use a combination of IF and ISBLANK functions to ensure that the calculation only occurs when both measures have values
DAX
IF(
ISBLANK([Measure A]) || ISBLANK([Measure B]),
BLANK(),
DIVIDE([Measure A], [Measure B]) - 1
)
2 Replies
- bhanu_gautamSuper User
Freece4802 To prevent all records from appearing when either [Measure A] or [Measure B] is blank, you can use a combination of IF and ISBLANK functions to ensure that the calculation only occurs when both measures have values
DAX
IF(
ISBLANK([Measure A]) || ISBLANK([Measure B]),
BLANK(),
DIVIDE([Measure A], [Measure B]) - 1
)- Freece4802Frequent Visitor
Thanks bhanu_gautam - in my context neither A nor B could be blank without the other being blank. Principally though you need the If statement to prevent the return of all records.
Thanks,