The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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 |
Solved! Go to Solution.
@KirkpM =DIVIDE(DISTINCTCOUNT(Table5[ID]),CALCULATE(DISTINCTCOUNT(Table5[ID]),Table5[EVENT]="1_BORN"),0)
@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
// 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.
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
@KirkpM , expected output is not clear to mean, Can you highlight and explain
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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
19 | |
18 | |
15 | |
13 |
User | Count |
---|---|
41 | |
36 | |
22 | |
22 | |
17 |