Power BI: calculate the (high) value of unique numbers

Sometimes, I need to calculate the average or the sum of something based on another column in which there are duplicate numbers or to calculate the maximum value of unique numbers. Let’s imagine that I have this data:

power bi

As we can see, in the “number” column, I have some duplicates and what I want, it is to calculate the average percentage by excluding them. For that, I will use this formula:

AVERAGEX(VALUES('table'[argument1]),CALCULATE(AVERAGE('table'[argument2])))

NOTE:

  • Replace “table” and “argument” by yours
  • To sum, use SUMX instead of AVERAGEX and SUM instead of AVERAGE

If it is correct, the result should be 44.39% (36.09% if I take in account the duplicate) according to excel.

Let’s check that, I will create a measure and put the formula:

power bi

I will format this measure in “percentage”:

power bi

Now I will create a card and put this measure:

power bi

And the result matches with excel:

power bi

Now, let’s say that I want to calculate the higher value for the unique number for this table:

power bi

I will use this formula:

AVERAGEX(SUMMARIZE('table','table'[argument1],"value",MAX('table'[argument2])),[value])

power bi

NOTE:

  • Replace “value” by yours
  • For the minimum value, use MIN instead of MAX

In excel, I got 70.57% (53.54% if I take in account all of them) and the measure matches it:

power bi

This article Power BI: find the maximum value of unique numbers may interest you.

Interesting Topics