cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KirkpM
Regular Visitor

Life events as a percentage of births

I am building a Power BI dashboard off an Excel document that mainly utilizes pivot tables. In a pivot table, I am able to create a calculation that identifies the proportion of all births that have a life event, i.e. what proportion of all the births for a specific time period (month of birth) had a pneumonia event?

The Pivot Table creates these values using the fields of EVENT and BirthDate (summarized as a birth month BMON). In the Pivot Table the column are assigned to EVENT, and the rows to BMON. The summation of values is the COUNT of ID (the unique individual reference number), with the Show Values As option set to "% OF", Base field = EVENT and Base item set as 1_BORN. The resulting values are then displayed as percentages. Of all the individuals born in the month of Feb 2019, 3.5% encountered a pneumonia event is an example result.

The data is structured with fields for ID, BDAT, BMON, EVENT, AGE, and EDAT (reference ID, birthdate, birth month, EVENT, age at event and event date). There may be multiple rows for each individual depending on the events they encountered.

In BI, I am unable to replicate this Excel calculation.

Thank you very much for any insights!

 

ID            BDAT             EVENT       AGE    EDAT             BMON

722817/29/20191_BORN07/29/20197/1/2019
722817/29/2019WEANED6910/6/20197/1/2019
11518811/16/20191_BORN011/16/201911/1/2019
1151913/9/20191_BORN03/9/20193/1/2019
1151913/9/2019PNEU.R1708/26/20193/1/2019
1151913/9/2019PNEU.R1738/29/20193/1/2019
1151923/7/20191_BORN03/7/20193/1/2019
1318182/1/2019PINKEYE1797/30/20192/1/2019
1318202/2/20191_BORN02/2/20192/1/2019
1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

@KirkpM =DIVIDE(DISTINCTCOUNT(Table5[ID]),CALCULATE(DISTINCTCOUNT(Table5[ID]),Table5[EVENT]="1_BORN"),0)

View solution in original post

6 REPLIES 6
wdx223_Daniel
Super User
Super User

@KirkpM =DIVIDE(DISTINCTCOUNT(Table5[ID]),CALCULATE(DISTINCTCOUNT(Table5[ID]),Table5[EVENT]="1_BORN"),0)

wdx223_Daniel:  Perfect!  That is exactly what I was looking for and really solved a big stumbling block.  Thank you!  KirkpM

Anonymous
Not applicable

// Careful: this measure honors all
// filters you might put on the data,
// so always make sure you understand
// what it returns. T is the table
// with the data you showed in your
// question. Thanks.

[Pneumonia %] =
var __pneumonia =
    CALCULATE(
        DISTINCTCOUNT( T[ID] ),
        KEEPFILTERS( T[EVENT] = "pneu.r" )
    )
var __born =
    DISTINCTCOUNT( T[ID] )
return
    DIVIDE( __pneumonia, __born )

daxer
Thanks very much for considering this question.  I had another request to provide clarrification.  Here's a further explanation.

 

An Excel pivot table delivers these counts of health events with a grouping focusing on the birth month.

KirkpM_6-1605719143234.png

 

I then use the Excel Pivot specifications mentioned in the original post (shown below) to determine the proportion affected (incidence rate) with the number born as the denominator. 

 

Here's the specifications for the Excel pivot summarization:

The Pivot Table creates the incidence values using the fields of EVENT and BirthDate (summarized as a birth month BMON). In the Pivot Table the column is assigned to EVENT, and the rows to BMON. The summation of values is the COUNT of ID (the unique individual reference number), with the Show Values As option set to "% OF", Base field = EVENT and Base item set as 1_BORN. The resulting values are then displayed as percentages. Of all the individuals born in the month of Feb 2019, 3.5% encountered a pneumonia event is an example result.

 

 

This is an example of the target output from an Excel Pivot Table

KirkpM_5-1605719053192.png


The categories of 1_BORN, SOLD and DIED are constants between different datasets, while the health conditions can be variable in name.

 

I hope this better explains the output goal. 

Thank you very much for considering this question! 

KirkpM

amitchandak
Super User
Super User

@KirkpM , expected output is not clear to mean, Can you highlight and explain



Learn Power BI - Full Course with Dec-2022, with new DAX functions like Window, Index, Offset !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Formatted Profit and Loss Statement with empty lines

Amitchandak
Thanks very much for your request for clarrification.

 

An Excel pivot table delivers these counts of health events with a grouping focusing on the birth month.

 

KirkpM_1-1605718422480.png

 

I then use the Excel Pivot specifications mentioned in the original post to determine the proportion affected (incidence rate) with the number born as the denominator. 

 

Here's the specifications for the Excel pivot summarization:

The Pivot Table creates the incidence values using the fields of EVENT and BirthDate (summarized as a birth month BMON). In the Pivot Table the column is assigned to EVENT, and the rows to BMON. The summation of values is the COUNT of ID (the unique individual reference number), with the Show Values As option set to "% OF", Base field = EVENT and Base item set as 1_BORN. The resulting values are then displayed as percentages. Of all the individuals born in the month of Feb 2019, 3.5% encountered a pneumonia event is an example result.

 

This is an example of the desired output

 

KirkpM_2-1605718485725.png


The categories of 1_BORN, SOLD and DIED are constants between different datasets, while the health conditions can be variable in name.

 

I hope this better explains the output goal. 

Thank you very much for considering this question! 

KirkpM

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors