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.
Hello,
Is there a way to implement below case statement as a measure or a new column in powerBI
Result = case when AVG_USER_ACTIVE < 10 and PercentUsage < 20.00 and Total > 180 then 1
else 0
end
I have looked into switch and IF but getting syntax error.
Thanks,
Kin
Solved! Go to Solution.
Maybe I haven't understood but uou can use a simple if :
result = if AVG_USER_ACTIVE < 10 and PercentUsage < 20.00 and Total > 180 then 1 else 0
And you can nest them :
result = if 1=1 and 1<>2 then
if 1<2 then 1 else 0
else 0
Use parenthesis to priorize and clarify.
Jean-Pierre Riehl
Result = if(AVG_USER_ACTIVE < 10,if (PercentUsage < 20.00,if (Total > 180,1,0)),0)
Hope this helps
Thanks,
Midhun
Maybe I haven't understood but uou can use a simple if :
result = if AVG_USER_ACTIVE < 10 and PercentUsage < 20.00 and Total > 180 then 1 else 0
And you can nest them :
result = if 1=1 and 1<>2 then
if 1<2 then 1 else 0
else 0
Use parenthesis to priorize and clarify.
Jean-Pierre Riehl
Thanks ! I created a custom column with what you suggested and now its working.
Just a note for future readers: You cannot create a measure as I thought I could initially and hence this question.
You can create a Measure or a Calculated Column with that logic. You just need to write it in DAX.
In DAX, IF() is a function and logical operators are && (AND) and || (OR).
(there are also AND() / OR() functions but it is less readable)
Here is the syntax :
= IF([AVG_USER_ACTIVE] < 10 && [PercentUsage] < 20.00 && [Total] > 180 ; 1 ; 0)
Notice the brackets [] to reference a Column or another Measure.
You can nest IF() functions in second and third parameters
In DAX, you also have the SWITCH function if you want different results with different inputs.
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 |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |