cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Parreirao2
Helper I
Helper I

Measure showing % or # of Attributes bellow average

Hi there,

 

Im trying to create a measure that would show me the percentage of Attributes bellow the average value of all attributes (filterable by date slicers).

Parreirao2_0-1651772367143.png

 

I understand this could be easily done by creating a calculated collumn, but due to performance impact I would like to prefer if this could be done using only one measure.

 

I've tried 

Bellow Average =
var CheckIf = IF([Total Value]<[Average Value],1,0)
var TempTable = SUMMARIZE(Table,Table[Attribute],"Atributes",CheckIf)
return
SUMX(TempTable,[Atributes])

 

but it's returning 0... 😕

 

Thanks in advance!

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Parreirao2 ,

Pls test the below:

avarage2 = calculate(AVERAGE('Table'[Value]),ALL('Table'))
sum2 = CALCULATE( SUM('Table'[Value]),ALL('Table'))
countblewavg = CALCULATE(COUNT('Table'[Attribute]),FILTER(ALL('Table'),'Table'[Value]<=[avarage2]))

output result:

vluwangmsft_0-1654067146962.png

And if you need slicer in your table ,change all to allselected.

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

5 REPLIES 5
v-luwang-msft
Community Support
Community Support

Hi @Parreirao2 ,

Pls test the below:

avarage2 = calculate(AVERAGE('Table'[Value]),ALL('Table'))
sum2 = CALCULATE( SUM('Table'[Value]),ALL('Table'))
countblewavg = CALCULATE(COUNT('Table'[Attribute]),FILTER(ALL('Table'),'Table'[Value]<=[avarage2]))

output result:

vluwangmsft_0-1654067146962.png

And if you need slicer in your table ,change all to allselected.

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

speedramps
Super User
Super User

Hi agaia Parreirao2

 

Ha Ha.  Think about it.  They wont wont.

 

If you use SUM they the Total and Avergae will be the same as the Total Value for each row.

 

You need to wrap them in a calculate ALL to get the average and totals.

for example ....

 

Average Value =
CALCULATE(
Average(Table[Value]),

ALL()
)

 

Please click the thumbs up and accept as solution button 😀

 

 

I thought of that and tried it, it still showed me zero :S

 

Check images bellow:

Parreirao2_0-1651775522243.pngParreirao2_1-1651775568942.png

Parreirao2_2-1651775599410.png

 

 

speedramps
Super User
Super User

Hi Parreirao2

 

You have not provided the DAX formulas for [Total Value] and [Average Value].  😀

 

They're in the attached image 😛


But here they are again:

Average Value = Average(Table[Value])

Total Value = Sum(Table[Value]

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors