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
Veblengood
Helper I
Helper I

Calculate with all function, maintaining filters applied

I am trying to calculate the sum of revenue for 2022 of a all products given that they have sales in a given periode (after 30.06.2022).

 

That is measure [Price 30.06] is not blank or 0. 

 

The following is my attempt:

 

IF([Price 30.06] <> blank() || [Price 30.06]<>0, calculate([Revenue], Dates[Year]==2022, ALL(Products_table))

 

However, the all() formula seems to ignore the IF() command, and adds all products for the period. 

 

Price 30.06 = calculated price after 30.06 // sum(DF_table(revenue)/sum(DF_table(quantity))

Revenue = sum(DF_table(revenue))
Products_table is connected to DF_table by item_id

Dates is connected to DF_table by dates column

 

1 ACCEPTED SOLUTION
Veblengood
Helper I
Helper I

Apologies, part of my inital syntax was incorrect, what solved it was the following:

 

CALCULATE(Revenue ,Dates[Year]==2022, KEEPFILTERS(Products[Products_ID] <>BLANK()), FILTER(ALL(Products),  'Price analysis'[Price 30.06] <> BLANK())),0)

View solution in original post

2 REPLIES 2
Veblengood
Helper I
Helper I

Apologies, part of my inital syntax was incorrect, what solved it was the following:

 

CALCULATE(Revenue ,Dates[Year]==2022, KEEPFILTERS(Products[Products_ID] <>BLANK()), FILTER(ALL(Products),  'Price analysis'[Price 30.06] <> BLANK())),0)
ribisht17
Super User
Super User

@Veblengood 

 

ribisht17_1-1658768008631.png

 

 

SalesAfter2Jan = CALCULATE(sum(SalesAfter[Sales]), FILTER(all(SalesAfter), SalesAfter[Date] >= DATE(2022,01,02)))

 

(after and including 2 Jan)

 

Regards,

Ritesh

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.