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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
Anonymous
Not applicable

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors