Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
How can i execute 2 values in if expressions? for example:
If(x=1,
Do A &&
Do B,
else do C
)
Thanks.
Solved! Go to Solution.
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.
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.
@wpf_
Without enough information, it is really hard to suggest a solution. could explain your question with practical examples?
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@wpf_
The output will be a single result form the if condition because it returns a scaler value:
If can be simple check
Price Group =
IF(
'Product'[List Price] < 500,
"Low",
"High"
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |