cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
srlabhe123 Member
Member

Nested Filter

Hi Team,

I have below data where I need to put filter on the customers which has order instance as 5. Once I get those customers I need to sum of the revenue of those customers only but revenue should be summed for all the order instance till 5.

 

Customer Order Instance revenue
Cust01110
Cust01220
Cust01330
Cust01440
Cust01550
Cust01660
Cust05160
Cust05270
Cust05380
Cust08190
Cust092100
Cust101110
Cust111120
Cust121130
Cust122140
Cust141150
Cust151160
Cust161170

 

Like in above example only Cust01 has orer instance 5, so the Cust01 shold be filtered out and then sum of revenue for Cust01 where Order Instance is <=5 so in this case revenue should be $150.

Please note Cust01 is filtered on the base of all those customers which reached upto order instance =5 and then put another filter to get sum of revenue for all order instance <=5, the 6th order instance wont be considered here.

This is kind of nested filter , kindly guide how it can be done in Power BI desktop may be with the help of DAX reference.

 

Thanks

Swapnil

2 ACCEPTED SOLUTIONS

Accepted Solutions
Microsoft v-ljerr-msft
Microsoft

Re: Nested Filter

Hi @srlabhe123,

 

Based on my test, you can firstly use the formula below to create a new calculate column in your table to indicate if a customer has order instance as 5.

HasFive = 
IF (
    COUNTROWS (
        FILTER (
            ALL ( Table1 ),
            Table1[Customer] = EARLIER ( Table1[Customer] )
                && Table1[Order Instance] = 5
        )
    )
        >= 1,
    1,
    0
)

 c1.PNG

 

Then you should be able to use the formula below to create a measure to calculate sum of the revenue of those customers only but revenue should be summed for all the order instance till 5.

Measure = 
CALCULATE (
    SUM ( Table1[revenue] ),
    FILTER ( Table1, Table1[HasFive] = 1 && Table1[Order Instance] <= 5 )
)

 m1.PNG

 

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

Highlighted
srlabhe123 Member
Member

Re: Nested Filter

it worked with bit work around, thank you 

View solution in original post

2 REPLIES 2
Microsoft v-ljerr-msft
Microsoft

Re: Nested Filter

Hi @srlabhe123,

 

Based on my test, you can firstly use the formula below to create a new calculate column in your table to indicate if a customer has order instance as 5.

HasFive = 
IF (
    COUNTROWS (
        FILTER (
            ALL ( Table1 ),
            Table1[Customer] = EARLIER ( Table1[Customer] )
                && Table1[Order Instance] = 5
        )
    )
        >= 1,
    1,
    0
)

 c1.PNG

 

Then you should be able to use the formula below to create a measure to calculate sum of the revenue of those customers only but revenue should be summed for all the order instance till 5.

Measure = 
CALCULATE (
    SUM ( Table1[revenue] ),
    FILTER ( Table1, Table1[HasFive] = 1 && Table1[Order Instance] <= 5 )
)

 m1.PNG

 

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

Highlighted
srlabhe123 Member
Member

Re: Nested Filter

it worked with bit work around, thank you 

View solution in original post

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (4,801)