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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
vafratis
Regular Visitor

Cumulative Total by number of SKU's

Hello, 

 

I am new to DAX expressions but after a lot of search I could not find a solution to my problem.

 

I want to create a line graph with cululative cost. Specifically: 

 

For each month I have to calculate the total item value for each item (some items appear multiple times each month), sort by value from largest to smallest, and then calculate cumulative value. 

ie.  

Item count 1 - value 200

item count 2 - value 350 (200 + 150)

item count 3 - value 450 (200 + 150 + 100)

 

Any ides on how to do it?


My data is inventory values and is as follows.

 

thanks in advance

 

 

MonthMaterial IDValue
01.2023A1100
01.2023A2150
01.2023A2200
01.2023A350
02.2023A410
02.2023A350
02.2023A2160
02.2023A180
03.2023A520
03.2023A250
03.2023A3120
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

I cannot understand your desired result.  Refer to my solution based on my understanding.  If thisisn't what youw ant, t hen show the expected result very clearly.

Ashish_Mathur_0-1699499924404.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

I cannot understand your desired result.  Refer to my solution based on my understanding.  If thisisn't what youw ant, t hen show the expected result very clearly.

Ashish_Mathur_0-1699499924404.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @vafratis ,

Please have a try.

First, create a new table with the following DAX expression:

Table =
SUMMARIZE (
    'Inventory Values',
    'Inventory Values'[Month],
    'Inventory Values'[Material ID],
    "Total Value", SUM ( 'Inventory Values'[Value] )
)

Next, sort the table by the “Total Value” column in descending order:

Sorted Table =
RANKX ( 'Table', [Total Value], DESC )

Now, add a new column to the table that calculates the cumulative value for each item:

Cumulative Value =
VAR CurrentMonth = 'Sorted Table'[Month]
VAR CurrentMaterialID = 'Sorted Table'[Material ID]
RETURN
    CALCULATE (
        SUM ( 'Sorted Table'[Total Value] ),
        FILTER (
            ALL ( 'Sorted Table' ),
            'Sorted Table'[Material ID] = CurrentMaterialID
                && 'Sorted Table'[Month] <= CurrentMonth
        )
    )

Finally, create a line graph with the “Month” column on the x-axis and the “Cumulative Value” column on the y-axis.

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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