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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Filter based list to use for calculation

Hi All,

I have scenario that I need to have sum(discount_amt) only for customers which has certain filter applied on it. I have query which gives me data customer wise discount applied., Now

1. I have to filter customers based on some other columns in same query and then 

2. Take thos ecustomers go to the all orders for those customers 

3. and then calculate discount amount for all orders.

 

Here in 1st step I may get 3 customers which has total(discoun_amt) as $100. But there may 10 orders for thsoe 3 customers which are getting filtered out due to filters in step 1.

Once I get 3 customers I need to clear the filters and goto all orders for those 3 customers and then sum(discount_amount) and show that as Promotion Discount.

 

Hope it helps...

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

You can try to use below measure to use the filtered result as the parameter to filter on original table:

Multi-filter result =
VAR filtred =
    CALCULATETABLE ( VALUES ( 'Sample'[Cust Id] ), ALLSELECTED ( 'Sample' ) )
RETURN
    SUMX ( FILTER ( ALL ( 'Sample' ), [Cust Id] IN filtred ), [Disc Amount] )

12.PNG

 

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

4 REPLIES 4
Anonymous
Not applicable

Cust IdSale IdSuccessYesterday5in90Disc Amount
123111YNN1000
234222YYY2000
123333YYY3000
456444YYN4000
789555NYN5000

 

For Ex in Above tBale if I apply filter as Success=Y,Yesterday=Y and 5in 90 =Y I get below customers 

 

Cust IdSale IdSuccessYesterday5in90Disc Amount
234222YYY2000
123333YYY3000

 

Then I need to clear all filters goto all sale IDs for Cust ID 234,123 which are below

 

Cust IdSale IdSuccessYesterday5in90Disc Amount
123111YNN1000
234222YYY2000
123333YYY3000

 

and then do sum(discount_amount) which is $6000, I wanted to do this in DAX if possible.

Hi @Anonymous,

 

You can try to use below measure to use the filtered result as the parameter to filter on original table:

Multi-filter result =
VAR filtred =
    CALCULATETABLE ( VALUES ( 'Sample'[Cust Id] ), ALLSELECTED ( 'Sample' ) )
RETURN
    SUMX ( FILTER ( ALL ( 'Sample' ), [Cust Id] IN filtred ), [Disc Amount] )

12.PNG

 

Regards,

Xiaoxin Sheng

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

Try this measure 

 

Total Discount = CALCULATE([Total Discount Amount], ALLEXCEPT('Cust Slicer', 'Cust Slicer'[Cust Id]) )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

whats cust slicer here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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