Forum Discussion
How to execute two values in if expressions?
How can i execute 2 values in if expressions? for example:
If(x=1,
Do A &&
Do B,
else do C
)
Thanks.
- Anonymous5 years ago
Hi wpf_ ,
If you want to execute two values, you must ensure that one result is returned. The metric returns an aggregate value, not multiple values.
I am not sure what your Do A&&Do B means, if you want to return two results, it won’t work, unless you merge the two results in text format, as follows
Sample data
Measure = IF ( MAX ( 'Table'[x] ) = 1, CALCULATE ( SUM ( 'Table'[Num] ), 'Table'[User] = "A" ) & "," & CALCULATE ( SUM ( 'Table'[Num] ), 'Table'[User] = "B" ), CALCULATE ( SUM ( 'Table'[Num] ), 'Table'[User] = "C" ) )& is used to connect two results, &","& can be a comma between the two results.
Result:
If you're still confused, you can provide sample data and expected results like me.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- AnonymousNot applicable
Hi wpf_ ,
If you want to execute two values, you must ensure that one result is returned. The metric returns an aggregate value, not multiple values.
I am not sure what your Do A&&Do B means, if you want to return two results, it won’t work, unless you merge the two results in text format, as follows
Sample data
Measure = IF ( MAX ( 'Table'[x] ) = 1, CALCULATE ( SUM ( 'Table'[Num] ), 'Table'[User] = "A" ) & "," & CALCULATE ( SUM ( 'Table'[Num] ), 'Table'[User] = "B" ), CALCULATE ( SUM ( 'Table'[Num] ), 'Table'[User] = "C" ) )& is used to connect two results, &","& can be a comma between the two results.
Result:
If you're still confused, you can provide sample data and expected results like me.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.