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

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.

Reply
Anonymous
Not applicable

How to determine multiple values or blanks in a row of data.

I have a report that shows the conditions of patients. Every patient will have at least one condition. Some patients have multiple conditions. I need to know the number of patients with multiple conditions (2+). The data looks like the sample below. The highlighted row shows a patient with multiple conditions. I would like a column that either shows the number of conditions a patient has or the number of blanks in the range of fields (five) so I can get a count. This would be a row by row evaluation.

 

Screenshot 2021-06-24 163725.jpg

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can follow the below steps to achieve it, please find the details in the attachment.

1. Select all conditions column and unpivot them first in Power Query Editor just as shown in the below screenshot:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgsMTBU0lHyyS8HkggUqwORM8IjZwzk+KamZJbmIjOwCMI0mCAbAzUVJmeKxyIzFFEkCXO4JmStIDZMhQUupyG5LhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Patient = _t, Diabetes = _t, COPD = _t, Asthma = _t, CAD = _t, HF = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Patient", type text}, {"Diabetes", type text}, {"COPD", type text}, {"Asthma", type text}, {"CAD", type text}, {"HF", type text}}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"Diabetes", "COPD", "Asthma", "CAD", "HF"}, "Conditions", "Value")
in
    #"Unpivoted Only Selected Columns"

yingyinr_1-1624870304718.png

2. Create a measure to get the count of conditions per patient

Count = CALCULATE(COUNT('Table'[Value]),'Table'[Value]<>"")

yingyinr_2-1624870506701.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can follow the below steps to achieve it, please find the details in the attachment.

1. Select all conditions column and unpivot them first in Power Query Editor just as shown in the below screenshot:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgsMTBU0lHyyS8HkggUqwORM8IjZwzk+KamZJbmIjOwCMI0mCAbAzUVJmeKxyIzFFEkCXO4JmStIDZMhQUupyG5LhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Patient = _t, Diabetes = _t, COPD = _t, Asthma = _t, CAD = _t, HF = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Patient", type text}, {"Diabetes", type text}, {"COPD", type text}, {"Asthma", type text}, {"CAD", type text}, {"HF", type text}}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"Diabetes", "COPD", "Asthma", "CAD", "HF"}, "Conditions", "Value")
in
    #"Unpivoted Only Selected Columns"

yingyinr_1-1624870304718.png

2. Create a measure to get the count of conditions per patient

Count = CALCULATE(COUNT('Table'[Value]),'Table'[Value]<>"")

yingyinr_2-1624870506701.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HashamNiaz
Solution Sage
Solution Sage

Hi @Anonymous !

 

You can use following DAX to create a custom column which will add non-blank occurences of medical conditions;

 

Medical Count = IF(NOT(ISBLANK(Table[Diabetes])) && Table[Diabetes] <> "", 1, 0) 
        + IF(NOT(ISBLANK(Table[COPD])) && Table[COPD] <> "", 1, 0)
 + IF(NOT(ISBLANK(Table[Asthma])) && Table[Asthma] <> "", 1, 0)
 + IF(NOT(ISBLANK(Table[CAD])) && Table[CAD] <> "", 1, 0)
 + IF(NOT(ISBLANK(Table[HF])) && Table[HF] <> "", 1, 0)

 

You can replace Table with your Table Name. The column will add up Non-Blanks for these 5 columns.

 

Regards,

Hasham

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.