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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Cumulative sum measure filtered by conditions on two diferente tables

Hi guys,

 

Need a bit of a help here with a dax measure.

 

For context, here's a printscreen of my current data model.

 

datamodel.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If I want to calculate the stock value in a given period I can use the following measure:

 

 

 

Stock =

CALCULATE(
    SUM(MaterialMovimento[Quantidade]);
    FILTER(ALL(Datas[Data]); Datas[Data] <= MAX(Datas[Data]))
)

 

 

 

But the problem starts when I want to calculate the stock value in given period of time, but just for materials which are slow movers. In other words, materials that don't have any sale in the past 3 months for any given date.

 

I've tried to create a measure to plot the stock value of slow movers over time but it's just not working. Here's the dax measure I'm unsuccesfully working on:

 

 

SlowMoversStock = 

VAR SlowMovers = CALCULATETABLE(Material; FILTER(ALL(ClienteFaturacao); ClienteFaturacao[DataCriacao] <= DATEADD(Datas[Data]; -3; MONTH)))

Return

CALCULATE(
    SUM(MaterialMovimento[Quantidade]);
    FILTER(ALL(Datas[Data]); Datas[Data] <= MAX(Datas[Data]));
    INTERSECT(Material; SlowMovers)
)

 

 


Unfortunatelly, with this measure I'm not able to get any value. All the graphics shown below were ploted with yaxis = SlowMoversStock and xaxis = Datas[Data]

 

currentmeasure.png

I think the problem it's somehow related with the date filtering (probably because of the relationships on the data model) I'm trying to perform when creating the calculated table to get the materials which are slow movers. You can see that I filter with a fixed date, the graphic shows values, as you can see in the code and image below.

 

 

SlowMoversStock = 

VAR SlowMovers = CALCULATETABLE(Material; FILTER(ALL(ClienteFaturacao); ClienteFaturacao[DataCriacao] <= DATE(2019; 7; 7)))

Return

CALCULATE(
    SUM(MaterialMovimento[Quantidade]);
    FILTER(ALL(Datas[Data]); Datas[Data] <= MAX(Datas[Data]));
    INTERSECT(Material; SlowMovers)
)

 

 

 

measurefixeddate.png

 

Any help would be appreciated. Thanks in advance!

2 REPLIES 2
kentyler
Solution Sage
Solution Sage

Any chance you could send a small power bi file with some sample data?





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable

Of course! Here you have it: https://drive.google.com/file/d/1-Pzaar2ZFnpurDpOdvIKhfIE3O-Q-87w/view?usp=sharinghttps://drive.goog...

Any doubt you have please feel free to contact me.

 

Thanks!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.