Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Average based on related value to selected

Hi everyone

 

I have a data set that looks like the below. 

 

What I'm after is to be able to display the average price for the location in which the selected customer resides. In an ideal world I'd have a slicer in which an end user can select e.g. "Joe Bloggs" and then have a measure into a card which would display the average price of people in London, e.g. £163.75.

 

Hoping someone can help with what this measure would look like as I'm a bit stuck!

 

Thanks

 

Customer NameLocationPrice
Joe BloggsLondon£100.00
Dan SmithNewcastle£50.00
Susie CampbellNewcastle£78.00
Kylie MinogueBrighton£135.00
David BeckhamLondon£180.00
Theresa MayLondon£250.00
BeyonceLondon£125.00

 

  • Anonymous try this measure

     

    Avg = 
    VAR __location = MAX( Table2[Location] )
    RETURN
    CALCULATE( AVERAGE( Table2[Price] ),ALL(Table2 ), Table2[Location] = __location )

2 Replies

  • Anonymous try this measure

     

    Avg = 
    VAR __location = MAX( Table2[Location] )
    RETURN
    CALCULATE( AVERAGE( Table2[Price] ),ALL(Table2 ), Table2[Location] = __location )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you!!