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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mmanwaring
Resolver I
Resolver I

Filter context breaking my calculation

Hi All,

Hope someone can shed some light on my problem.

I have a stock movement calculation which is pivoted by col = sku and row= year.
The problem is that the table has to be filtered to the correct movement types.

example.
This works for running total:

CALCULATE(SUM('Table'[TrueQuantity]), DimDates[Date] <= MaxDate , ALL(DimDates) )

 

1.png

this does not:

CALCULATE(SUM(MovementsInOut[TrueQuantity]), FILTER( MovementsInOut , movementsInOut[movementtype] IN {100,392,227,235,225}), DimDates[Date] <= MaxDate , ALL(DimDates) )


2.png

I would like to avoid creating an additional table to the model so if the filter can work within the calculation that would be perfect

thank you

Mike

7 REPLIES 7
amitchandak
Super User
Super User

@mmanwaring , Try like

CALCULATE(SUM(MovementsInOut[TrueQuantity]), FILTER( MovementsInOut , movementsInOut[movementtype] IN {100,392,227,235,225}), filter(all(DimDates) ,DimDates[Date] <= MaxDate ))

Hi, Thank you for your reply.
It does however not change the results.
Mike

@mmanwaring ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Hi amitchandak

 

----


Thank you Mike

@mmanwaring , No access, applied for it

Hi

The measure works fine until i add the filter for the movement types then it breaks. It will be ok if i make a new table but not if i calculate a new table within the measure?

Thanks Mike

Hello

Sorry try now  sample 

 

thank you

Mike

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.