Forum Discussion

karkar's avatar
karkar
Helper III
9 years ago
Solved

Percentage calculation

 

 

Hello Team,

 

I want to calculate the percentages in Power BI  using the following data below. I want a single row per PAT as shown after summarizing data along with the percentages for each.

Later, I wish to make a trend chart by Month or by day. For example since both 001 and 002 belong to the same month (say January2017) we should be able to plot 5/8*100=62.5%.

 

PAT       NUMERATOR       DENOM       MONTH

001           0                          1             06JAN2017 

001           1                          1            07JAN2017

001           0                          1            08JAN2017

001           1                          1           09JAN2017

001           0                          1           10JAN2017

001           0                          1           11JAN2017

002           1                          1           06JAN2017

002           1                          1          07JAN2017

002           1                          1         08JAN2017

 

 WANT

 

PATIENT     Percent= (NUM/DEN) *100

001                2/5*100= 40%            

002                3/3*100= 100%            

 

 

  • karkar

     

    Measure = DIVIDE ( SUM('Table'[Numerator]), SUM('Table'[Denomenator]), 0)

7 Replies

  • Sean's avatar
    Sean
    Community Champion

    karkar

     

    Measure = DIVIDE ( SUM('Table'[Numerator]), SUM('Table'[Denomenator]), 0)

    • karkar's avatar
      karkar
      Helper III

      Hello Sean,

       

      Thank you. Though it got me the result, I am unable to format the Measure as a %age.

       

      I am getting the below:

       

          PAT        NUM      DEN       MEASURE

          001          2             6              0.33     instead of 33%

          002          3             3              1     instead of a 100%

       

       

       

      Also if i add other fields like Name etc we are gettign the calculation right but just that we are having more than one row per PAT.

      since the NUM and DEN are already summarized fields using SQL code. How can we summarize that to just have one record per patient?

       

       

      Thank you

       

      • Sean's avatar
        Sean
        Community Champion

        Select the Measure - go to the Modeling Tab and change the Format