cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
twikle
Frequent Visitor

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
yingyinr
Community Support
Community Support

Hi @twikle ,

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
yingyinr
Community Support
Community Support

Hi @twikle ,

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

HashamNiaz
Solution Sage
Solution Sage

Hi @twikle !

 

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
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors