Forum Discussion

Jeremy19's avatar
Jeremy19
Icon for Helper III rankHelper III
5 years ago
Solved

Min/max/AVG by filters data

Hello,

 

I have two tables "DB" 

NameVar1DateCondition
A100043831C1
A110043832C1
A136243831C2
A74043832C2
B123743831C1
B135443832C2
B93243836C2
B92243837C1
C78843832C2
C89243833C2
C108643834C1
D136343835C1
D155543838C2

 and Player

NamePosition
AG1
BG1
CG1
DG2

 

I make a report by player so I filter my page by a name column. However, I would like to have measures that return the min / max / average of the maximum of players in the same position as that of the selected player. Is it possible ? In addition, only on condition C1. For exemple if I select player A, min =1086, avg=1141 and max=1237.

 

Thanks !!

  • Hi Jeremy19 ,

     

    Is this what you want? Or you want a "Player" slicer?

     

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

8 Replies

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    Please try this measure expression to get your desired result.  This one is the min, but you can adapt it for max and avg as needed.  Note this assumes you have no relationship between the tables and the Name column from the Positions table is used in the slicer.  Note I got a min of 922 since name B is in same position.  Replace Var1 and Positions with your actual table names.

     

    Min Var1 =
    VAR vThisName =
        VALUES ( Positions[Name] )
    VAR vNamesSamePosition =
        CALCULATETABLE (
            VALUES ( Positions[Name] ),
            VALUES ( Positions[Position] ),
            ALL ( Positions[Name] ),
            NOT ( Positions[Name]
                IN vThisName )
        )
    RETURN
        CALCULATE (
            MIN ( Var1[Var1] ),
            TREATAS (
                vNamesSamePosition,
                Var1[Name]
            ),
            Var1[Condition] = "C1"
        )

     

    Pat

     

    • Jeremy19's avatar
      Jeremy19
      Icon for Helper III rankHelper III

      Thank you very much, this is not far from what I need. No need for the option to ignore the player but I just need to remove the NOT. On the other hand the problem again is that I need the MIN but among the MAX of each player in the same position (1100,1237 or 1086). While here I have the min on all the values of the players of the same position.

    • Jeremy19's avatar
      Jeremy19
      Icon for Helper III rankHelper III

      The expected result is to have the 3 measurements as described to be able to construct a graph as below.

       

      The lines representing min / max of the max of the players of the same position, the point the average and the bar the max value of the player.

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi Jeremy19 ,

     

    " In addition, only on condition C1. For exemple if I select player A, min =1086, avg=1141 and max=1237."

     

    Regarding the example you gave, I can’t understand how the maximum, minimum and average values are calculated. Could you explain it with mathematical formulas?

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

     

    • Jeremy19's avatar
      Jeremy19
      Icon for Helper III rankHelper III

      Ok,

      Step 1 : select the maximum values per player of the same position and for condition C1. If I select a player who has the G1 position : 1100 for A, 1237 for B and 1086 for C. 

       

      Step 2 : Three measures to obtain the min / avg / max among the values of step 1

       

      In my example if I select player D as he is alone in his group the final result will be 1363 for min, avg and the max.

      • v-lionel-msft's avatar
        v-lionel-msft
        Icon for Community Support rankCommunity Support

        Hi Jeremy19 ,

         

        Is this what you want? Or you want a "Player" slicer?

         

         

        Best regards,
        Lionel Chen

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.