The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello Community,
I have the following challenge concerning DAX with the desktop application of Power BI:
My table contains messages from different devices. There might be multiple messages from one device and each message has a dedicated severity level (1=warning, 2=critical, 3=error).
Based on this table I want to find out two things with measures/DAX:
Example table:
device_id | message_id | severity_level | message_title |
111 | 1_1 | 1 | warning |
222 | 2_1 | 1 | warning |
222 | 2_2 | 2 | critical |
333 | 3_1 | 1 | warning |
333 | 3_2 | 1 | warning |
333 | 3_3 | 1 | warning |
333 | 3_4 | 3 | error |
444 | 4_1 | 3 | error |
555 | 5_1 | 2 | critical |
555 | 5_2 | 3 | error |
555 | 5_3 | 3 | error |
666 | 6_1 | 2 | critical |
777 | 7_1 | 1 | warning |
777 | 7_2 | 1 | warning |
777 | 7_3 | 1 | warning |
777 | 7_4 | 1 | warning |
The quantity results of this example table should be:
Best regards and thank you for your support.
knre
Solved! Go to Solution.
You could try something like
Num max level 1 =
var level1 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 1)
var level3 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 3)
return COUNTROWS( EXCEPT( level1, level3 ) )
Num max level 2 =
var level2 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 2)
var level3 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 3)
return COUNTROWS( EXCEPT( level2, level3 ) )
Hi:
For the Warning piece you could try:(as Calc Col's) The first Calc Col just shows how many entries per device and is referred to in the next CC.:
You could try something like
Num max level 1 =
var level1 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 1)
var level3 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 3)
return COUNTROWS( EXCEPT( level1, level3 ) )
Num max level 2 =
var level2 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 2)
var level3 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 3)
return COUNTROWS( EXCEPT( level2, level3 ) )
Nice, that's it 🙂 Thank you!
Just one thing I had to change for Num max level 1 at var level3:
var level23 = CALCULATETABLE( VALUES( 'Table'[device id]), 'Table'[severity] = 2 || 'Table'[severity] = 3)
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
67 | |
36 | |
21 | |
18 | |
15 |
User | Count |
---|---|
124 | |
39 | |
30 | |
24 | |
22 |