Forum Discussion
Anonymous
1 year agoNot applicable
Adding an IF condition to a Measure
Hello, I am trying to reply an Excel Rule into DAX Measure The idea is: When Result < 0, sum Result + Last Month C/C (superior line), otherwise, just reply the result So just reply the result wh...
Anonymous
1 year agoNot applicable
Hi Anonymous ,
I create a table as you mentioned.
Then I think you can create a calculated column.
C/C =
VAR _Current = 'Table'[Result]
VAR _Previous =
CALCULATE (
SUM ( 'Table'[Result] ),
FILTER ( 'Table', 'Table'[Month] < EARLIER ( 'Table'[Month] ) )
)
RETURN
_Current + COALESCE ( _Previous, 0 )
I also think you can create two measures and here are the DAX codes.
Result_Color = IF(MAX('Table'[Result])<0,"Red","Black")C/C_Color = IF(MAX('Table'[C/C])<0,"Red","Black")
Next make them into Conditional formatting.
Finally you will get what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
1 year agoNot applicable
But this last line isnt respecting the rule: if the last month result's be positive, just reply current month result