Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Grouping and Comparing - maybe?

I have a dataset inclusive of customer spend history.  I am looking for a pragmatic way to compare one selected customer, with all others.  The others being "grouped".

 

For instance - Imagine a trendline...show me the average monthly spend of "Customer A" as comapred to all other Customers.  The output would be two lines, one representing Customer A, the other line - all other customers.

 

The motivation for this is to be able compare...

 

All feedback welecome!

  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Anonymous ,

    I'd like to suggest you take a look at following links to know more about 'allselected' function and 'in' operator.

    The definitive guide to ALLSELECTED

    The IN operator in DAX

    Please understand that this link is provided with no warranties or guarantees of content changes, and confers no rights.

    Regards,

    Xiaoxin Sheng

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    You can write two measures to calculate and filter on selected records.

    For example:

    AVG selected =
    VAR currDate =
        MAX ( Table[Date] )
    RETURN
        CALCULATE (
            AVERAGE ( Table[Amount] ),
            FILTER (
                ALL ( Table ),
                YEAR ( Table[Date] ) = YEAR ( currDate )
                    && MONTH ( Table[Date] ) = MONTH ( currDate )
                    && [Customer] IN ALLSELECTED ( Customer[Customer] )
            )
        )
    
    AVG Inverse =
    VAR currDate =
        MAX ( Table[Date] )
    RETURN
        CALCULATE (
            AVERAGE ( Table[Amount] ),
            FILTER (
                ALL ( Table ),
                YEAR ( Table[Date] ) = YEAR ( currDate )
                    && MONTH ( Table[Date] ) = MONTH ( currDate )
                    && NOT([Customer] IN ALLSELECTED ( Customer[Customer] ))
            )
        )

    Regards,
    Xiaoxin Sheng

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous 

       

      I see what you've done here, and less specific to the actual calculation, can you help me undertstand how to simply group the Selected vs. Not Selected in a simple DAX statement so that I can compare the two "groups"?

       

      Much appreciated.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        I'd like to suggest you take a look at following links to know more about 'allselected' function and 'in' operator.

        The definitive guide to ALLSELECTED

        The IN operator in DAX

        Please understand that this link is provided with no warranties or guarantees of content changes, and confers no rights.

        Regards,

        Xiaoxin Sheng