cancel
Showing results for
Did you mean:
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

 72281 7/29/2019 1_BORN 0 7/29/2019 7/1/2019 72281 7/29/2019 WEANED 69 10/6/2019 7/1/2019 115188 11/16/2019 1_BORN 0 11/16/2019 11/1/2019 115191 3/9/2019 1_BORN 0 3/9/2019 3/1/2019 115191 3/9/2019 PNEU.R 170 8/26/2019 3/1/2019 115191 3/9/2019 PNEU.R 173 8/29/2019 3/1/2019 115192 3/7/2019 1_BORN 0 3/7/2019 3/1/2019 131818 2/1/2019 PINKEYE 179 7/30/2019 2/1/2019 131820 2/2/2019 1_BORN 0 2/2/2019 2/1/2019
1 ACCEPTED SOLUTION
Super User

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

6 REPLIES 6
Super User

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

Regular Visitor

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 )``````
Regular Visitor

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.

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

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

Super User

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

Regular Visitor

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.

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

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

Announcements

#### 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.

#### 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!

#### 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