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
irnm8dn
Post Prodigy
Post Prodigy

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!

1 ACCEPTED SOLUTION

Hi @irnm8dn ,

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @irnm8dn ,

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft 

 

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.

Hi @irnm8dn ,

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.