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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jdat010
Regular Visitor

Struggeling with LastNonBlank and Rolling SUM

Hi everyone!

 

Your help is really needed, so please have a look on my problem:

 

To understand the nature of the data better: It's planning stock data. The measure I need is an average (but must include blank values, so it might be better to take a sum and divide it by days)

 

The data is provided as snapshots, only values that changed compared to the last snapshot date.

Product SnapshotDate PlanDate Qty
A 01.11.2022 30.11.2022 50
A 05.11.2022 01.12.2022 150
A 07.11.2022 01.12.2022 170
A 07.11.2022 02.12.2022 20
A 08.11.2022 03.12.2022 30

jdat010_0-1667558512166.png

 

1) the orange lines marks the lines where I need the last non blank qty, because this is the last row with the latest snapshot value

2) I need a rolling sum over the next 3 days (excluding the acutal day), regardless if there is a value or not, if there is not value, then it should be 0

3) the rolling sum needs to be divided by those 3 days to get an average

4) At the end the result in the visual should look like this, even with no filter set on one of the days:

 

jdat010_1-1667559030546.png

 

I found already several examples and some got me half the way, but at the end it was always needed to show the plandate in the matrix or set at least a filter on the report.

 -> https://www.daxpatterns.com/week-related-calculations/ 

Has a good example in calculating a moving average (in the past), but one of the requirements is to include blank values, because there aren't rows on every single day.

 

1 REPLY 1
daXtreme
Solution Sage
Solution Sage

Hi @jdat010 

 

The fact that your snapshots only contain data that's changed does not mean you can't make it into a full snapshot using Power Query. If you do, it'll be easier to work with this and your DAX will be easier and faster. Being good at Power BI does not mean being good at writing complex DAX. It means, first and foremost, being able to create models that are adequate to the tasks at hand (and hence simple). Then your DAX becomes simple and fast as well, which is what expertise means.

 

So, please work first on your model first and the rest will come naturally.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.