Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Comparing a value to the values total based on a matching dimension.

Hi everyone,

 

In my example, I have 4 unique stores with different store types (small, medium and large format). 

To see if a store performs better or worse than the average of similar store formats, I wants to add a column (marked red in example below) that keeps the average of all the stores with similar format.  So in my example below, the average of large store formats is 100 (=(50+150)/2).

When I have slicers in place, I somehow cant figure out how I can fix this. Can anyone help me? Thanks so much in advance!

 

Example:

Store IDStore formatAverage revenueAverage of store classification
1Small1010
2Medium2025
3Large50100
4Large

150

100

5Medium

30

25

 

 

 

  • Anonymous Try:

     

    Measure = 
      VAR __Format = MAX('Table'[Store format)
      VAR __Table = FILTER(ALL('Table'),[Store format] = __Format)
      VAR __Result = AVERAGEX(__Table,[Average revenue])
    RETURN
      __Result

     

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous Try:

     

    Measure = 
      VAR __Format = MAX('Table'[Store format)
      VAR __Table = FILTER(ALL('Table'),[Store format] = __Format)
      VAR __Result = AVERAGEX(__Table,[Average revenue])
    RETURN
      __Result

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Greg_Deckler ,

       

      [edit] It worked! Thanks for the quick reply and solution. Really helpful! 😄
      Thanks for your reply! I have used your answer, but it seems it returns the average revenue per row, and not the average of multiple rows in that new column. So the revenue value stays the same. 

      Im not quite following the steps in the measure example. What does the MAX('Table'[Store format]) do in this example?

      Again, thanks for taking the time, I really appreciate it 🙂