Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
t_guet01
Helper I
Helper I

How to filter measures by using 2 slicers to compare customers?

Hi guys,

 

I am currently trying to figure out the following: how would my revenue change if customer A got the prices customer B has?

 

Please find the file here: https://www.dropbox.com/sh/2vxnjdgt8vk0pxs/AABo2Mv3XMw9Mz-ujIUYrqSFa?dl=0

 

I want this comparison to be dynamic, i. e. I set up two slicers to select the two customers I want to compare. My input table is a transaction table.

 

t_guet01_1-1638208089314.png

 

 

In the example of the screenshot, I compare Customer "123" with customer "456". They have the products "ABC", "DEF", "GHI", and "JKL" in common. How would the revenue of customer "123" change if they get the (average) prices customer "456" gets? Since customer "456" does not purchase product "MNO", I would like to assume the price stays stable for customer "123" for product "MNO", i.e. 45,30 €. Since product "DEF" is purchased twice by customer "456", I assume the weighted average to be customer "123"'s price, i.e 11,70 €. 

Revenue customer A with own prices: 3929 €

Revenue customer A with "456" prices: 3890 €

Target measure: -0,99 % = (3890 - 3929) / 3929

 

Any ideas?

Thanks very much!

 

Best

Tom

 

3 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

Here's a way to calculate the alternative revenue:

Customer 1 Alt Revenue = 
VAR Cust1 = SELECTEDVALUE ( CustomerSelection1[CustomerID] )
VAR Cust2 = SELECTEDVALUE ( CustomerSelection2[CustomerID] )
VAR Products1 = CALCULATETABLE ( VALUES ( SalesData[ProductID] ), SalesData[CustomerID] = Cust1 )
VAR Products2 = CALCULATETABLE ( VALUES ( SalesData[ProductID] ), SalesData[CustomerID] = Cust2 )
VAR SharedProductsRev =
    ADDCOLUMNS (
        INTERSECT ( Products1, Products2 ),
        "@Qty",   CALCULATE ( SUM ( SalesData[Quantity] ), SalesData[CustomerID] = Cust1 ),
        "@Price", CALCULATE ( [AveragePrice], SalesData[CustomerID] = Cust2 )
    )
VAR Cust1OnlyProductsRev =
    ADDCOLUMNS (
        EXCEPT ( Products1, Products2 ),
        "@Qty",   CALCULATE ( SUM ( SalesData[Quantity] ), SalesData[CustomerID] = Cust1 ),
        "@Price", CALCULATE ( [AveragePrice], SalesData[CustomerID] = Cust1 )
    )
RETURN
    SUMX ( SharedProductsRev, [@Qty] * [@Price] )
        + SUMX ( Cust1OnlyProductsRev, [@Qty] * [@Price] )

 

From here, defining the Target measure should be straightforward.

View solution in original post

CNENFRNL
Community Champion
Community Champion

Tricky game of playing with filters,

Screenshot 2021-11-30 105732.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

CNENFRNL
Community Champion
Community Champion

Tricky game of playing with filters,

Screenshot 2021-11-30 105732.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Tricky game of playing with filters,

Screenshot 2021-11-30 105732.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

CNENFRNL
Community Champion
Community Champion

Tricky game of playing with filters,

Screenshot 2021-11-30 105732.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

AlexisOlson
Super User
Super User

Here's a way to calculate the alternative revenue:

Customer 1 Alt Revenue = 
VAR Cust1 = SELECTEDVALUE ( CustomerSelection1[CustomerID] )
VAR Cust2 = SELECTEDVALUE ( CustomerSelection2[CustomerID] )
VAR Products1 = CALCULATETABLE ( VALUES ( SalesData[ProductID] ), SalesData[CustomerID] = Cust1 )
VAR Products2 = CALCULATETABLE ( VALUES ( SalesData[ProductID] ), SalesData[CustomerID] = Cust2 )
VAR SharedProductsRev =
    ADDCOLUMNS (
        INTERSECT ( Products1, Products2 ),
        "@Qty",   CALCULATE ( SUM ( SalesData[Quantity] ), SalesData[CustomerID] = Cust1 ),
        "@Price", CALCULATE ( [AveragePrice], SalesData[CustomerID] = Cust2 )
    )
VAR Cust1OnlyProductsRev =
    ADDCOLUMNS (
        EXCEPT ( Products1, Products2 ),
        "@Qty",   CALCULATE ( SUM ( SalesData[Quantity] ), SalesData[CustomerID] = Cust1 ),
        "@Price", CALCULATE ( [AveragePrice], SalesData[CustomerID] = Cust1 )
    )
RETURN
    SUMX ( SharedProductsRev, [@Qty] * [@Price] )
        + SUMX ( Cust1OnlyProductsRev, [@Qty] * [@Price] )

 

From here, defining the Target measure should be straightforward.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.