cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors