Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Averaging over multiple rows (all function?)

I am trying to get a measure (below). Basically the flag should evaluate to a 1 on both rows because NLR has an average of greater than 0 when looking at the complete table (not just the row current row).

 

Measurer =
If(CALCULATE(AVERAGEX(f_GW,f_GW[Revenue]),FILTER(f_GW,f_GW[LRFlag]="NLR"))<1,2,1)

 

LRFlagModel NameRevenueMeasure
LRGeneritech              180,0002
NLRGeneritech           1,250,0001

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous

 

You may use ALLSELECTED Function  instead of ALL Function.

 

Measure1 =
CALCULATE (
    AVERAGEX ( f_GW, f_GW[Revenue] ),
    FILTER ( ALLSELECTED ( f_GW ), f_GW[LRFlag] = "NLR" )
)

1.png

Regards,

Cherie

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Perhaps:

 

If(AVERAGEX(FILTER(ALL(f_GW),f_GW[LRFlag]="NLR"),f_GW[Revenue])<1,2,1)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for the response Greg. Unfortunately this seems to be averaging across all rows in the underlying source table, not just this visualization table. Is there anyway to have average  for just the records displayed on table?

 

Z

Hi @Anonymous

 

You may refer to below measure. If it is not your case, please explain more about your expect output.

Avg =
CALCULATE (
    AVERAGEX ( f_GW, f_GW[Revenue] ),
    FILTER ( ALL ( f_GW ), f_GW[LRFlag] = "NLR" )
)

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

The problem is it includes all Model Names in the average.   Notice in the tables below the Average (Measure) is 333,333,33 no matter if I select ABC Company or Generitech? If I select ABC Company it should be 500,000 on both lines and if I select Generitech it should be 250,000 on each line. Basically I need the measure to take into account which model name is selected and it is not. Thanks for the help!

 

sample2.JPGsample1.JPG

Hi @Anonymous

 

You may use ALLSELECTED Function  instead of ALL Function.

 

Measure1 =
CALCULATE (
    AVERAGEX ( f_GW, f_GW[Revenue] ),
    FILTER ( ALLSELECTED ( f_GW ), f_GW[LRFlag] = "NLR" )
)

1.png

Regards,

Cherie

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

That did it! Thanks Cherie. - Don't know why but it doesn't have "Accept as a Solution" next to your reply.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors