Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Calculate ratio

Hi,

 

I need to calculate the ratio of some fields. I have the following data, this is the structure of the data. 

IDNumbersDateHour
1205-13-202010:00
1105-13-202011:00
2305-13-202010:00
3305-13-202010:00
3105-13-202011:00

 

I need to create a new column or measure, don't know whats better to use, to calculate the ratio.

I need the follow numbers

IDRatio
130%
230%
340%

 

I can use a measure with SUM('table1'[numbers]) and then use this in a card to show the total numbers. I can also click here in the desktop version to "show percent of grand total" which will give me 100%. When I to this in a table I get the correct numbers as show above.

 

But I want to show an average of these ratio's and I just can't manage to do this with measure. Because I need the total numbers of a day of all ID together and divide this with the total numbers of the ID itself. In this way you get the ratio of each ID.

 

I hope someone can help me with this. 

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    You could a default SUM aggregation on Number and use "Show as...Percent of grand total".

     

    Anonymous 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Greg_Deckler Thank you for your reply.

      I know I can use a percent of grand total, but I want a measure that's calculation the average of all the ratio's of all ID's. And I can't do that with the "percent of grand total" function. Hope you understand my question, sorry for my garbage English.

      • az38's avatar
        az38
        Community Champion

        Hi Anonymous 

        try a measure

        Measure = 
        DIVIDE(
        CALCULATE(SUM(Table[Numbers]), ALLEXCEPT(Table, Table[ID]) ),
        CALCULATE(SUM(Table[Numbers]), ALL(Table) )
        )
  • v-chuncz-msft's avatar
    v-chuncz-msft
    Community Support

    Anonymous 

     

    You may use the measure below.

    Measure =
    DIVIDE (
        AVERAGEX ( VALUES ( Table1[ID] ), CALCULATE ( SUM ( Table1[Numbers] ) ) ),
        CALCULATE ( SUM ( Table1[Numbers] ), ALLSELECTED ( Table1[ID] ) )
    )
    

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you both v-chuncz-msft and az38 . Both of the solutions works with a measure. 

       

      Is this formula also possible to use as an extra column instead of a measure? 

      • az38's avatar
        az38
        Community Champion

        Anonymous 

        yes, it should be fine