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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
SophRow
Resolver II
Resolver II

Calculate prevalence by disease in unpivoted table

Hi experts,

 

I have a large dataset that looks (simplified!) like this:

 

SophRow_0-1687327560760.png

For diseases, 0 = no disease and 1 = disease.

 

What I want to show is prevalence by cohort i.e., incidence / Total # participants in particular cohort. 

 

I also want to keep the Participant Number so I can later slice by gender age etc from a dimension table. 

 

I have played around with unpivoting the Disease columns and can calculate total incidence, but am not able to get prevalence to work on a visual (it always comes out at 100%). 

 

My DAX was simply:

 

 

Total Incidence = COUNTROWS('Table')

Total Distinct Participants = DISTINCTCOUNT('Table'[Participant Number])

Prevalence = DIVIDE([Total Incidence],[Total Distinct Participants])

 

Whilst this work in card visuals and can be filtered by cohort, it doesn't work on a bar chart to show by condition:

 

SophRow_1-1687328067127.png

(Condition is the name of the unpivoted column).

 

Any advice greatly appreciated.

 

Best,

Soph

 

0 REPLIES 0

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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