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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Cumulative total and limit number of displayed items on a visual

Hello,

 

I am working on a stock management dashboard and cannot figure out how to do the following.

 

Initial data:

I have a big table on a server with available product stock data for 2020 02 01 data (it shows initial remaining stock for each product for 2020 02 01 date).

This table also contains all sales and purchase data, where sales is a negative number and purchase is a positive number. 

This allows me to see what is the stock situation for certain date (by summing initial stock and sales/purchase operations).

 

What I need to do:

I want to make a Matrix visual which showed stock situation for last 7 days (in columns) by product (in rows). 

 

My best guess so far is:

 

CurrentStock = 
VAR lDate = CALCULATE(LASTDATE(Stock[Date]);ALL(Stock[Quantity]))
RETURN
IF(SELECTEDVALUE(Stock[Date])>lDate;BLANK();
    CALCULATE([TotalQuantity];
        FILTER(ALLSELECTED(Stock[Date]);
            Stock[Date] <=MAX(Stock[Date]))))

If fails to show value on each of the dates. Some dates are blanks (when there are no product movements). Also I cannot find a solution to display only 7 last days in columns.

 

If someone has any suggestions I would be grateful.

 

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

As mentioned by @amitchandak , maybe you need to create a calendar table .

And could you please tell me whether your problem has been solved? 

If not ,please kindly  share sample data  and expected result .

It will make it easier for us to understand and  solve your problem.

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

Join it with date table and then try to do it something like this

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=maxx(date,date[date])))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.