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
PBInterest
Frequent Visitor

Nested filters for case like statement

I have two lines of business and I want to summarize values over the combined lines of business. This data lives in the same table but some attributes only apply to one or the other business line. Both lines of business share some common rules which I filter on using calculate in a measure. One of the business lines has a filter unique to it. I am trying to figure out the best way to write a measure that first uses the common filters, but for one line of business add a second filter that won't filter out the rest of the totals for the other business line.

 

The current measure incorporates only the common filters:

 

What I have:

TotalSales:=CALCULATE ( SUM(SalesTotal), CommonFilterA= 1, CommonFilterB = 2)

 

What I need to add:

<Filter Condition> When BusinessLineId = 2 then SUM(TotalSales) where the SalesType = Retail.

 

I need to add a filter that applies to only one of the two business lines. I need to be able to summarize SalesTotals for both lines of business. I was hoping there was a way I could do this without creating two measures, one for each business line, and then summarizing both. Is there a way to write this in a single DAX statement?

 

Thanks.

 

 

1 REPLY 1
amitchandak
Super User
Super User

@PBInterest , based on what I got

 

calculate([TotalSales],filter(Table, [BusinessLineId] <> 2)) + calculate([TotalSales],filter(Table, [BusinessLineId] = 2 && [SalesType] = "Retail" ))

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.

Top Solution Authors