Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
knre
New Member

Count devices depending on their most severe state in a table of messages

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:

  • Quantity of devices that only have messages with severity level 1 (no messages with severity level 2 or 3)
  • Quantity of devices that have messages with severity level 2 (and maybe with severity level 1 but not with severity level 3)

Example table:

device_idmessage_idseverity_levelmessage_title
1111_11warning
2222_11warning
2222_22critical
3333_11warning
3333_21warning
3333_31warning
3333_43error
4444_13error
5555_12critical
5555_23error
5555_33error
6666_12critical
7777_11warning
7777_21warning
7777_31warning
7777_41warning

 

The quantity results of this example table should be:

  • Quantity of devices with maximum severity level 1 (warning): 2 (111, 777)
  • Quantity of devices with maximum severity level 2 (critical): 2 (222, 666)
  • Quantity of devices with severity level 3 (error): 3 (333, 444, 555) => easy with filter and distinct count 😊

Best regards and thank you for your support.

knre

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

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 ) )

View solution in original post

3 REPLIES 3
Whitewater100
Solution Sage
Solution Sage

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.:

 

Freq 1 (entries/device)=
var device = 'Table'[device_id]
var severity = 'Table'[severity_level]
return
COUNTROWS(FILTER(ALL('Table'),
'Table'[Device_id] = device
&& 'Table'[severity_level] = severity))
 
Severe CT = IF('Table'[severity_level]=1 && 'Table'[Freq 1] = 'Table'[Freq],"Warning",BLANK())
 
I'm having trouble with the second criteria. I like the methode johnt75 is doing but not sure with this example.
johnt75
Super User
Super User

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)

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.