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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Fistachpl
Helper III
Helper III

Cumulative sales

Hello I need to calculate the cumulative sales

On the page I have filters apllied and I just need to calculate the mesaure Sold CY but do it in a cumulative way.

 

First column is a month

Fistachpl_0-1718029579181.png

 

 

It should be:
Jan 260
Feb 260 +339 
march 260 + 339 +260 etc.

 

 

I try to do this by:

 

Cumulative sale =

VAR _aktualnyMiesiac = SELECTEDVALUE('TMiesiące'[Nr miesiąca]) //Current month

 

VAR _cumulativeSales =

    CALCULATE(

        SUMX('Dane sprzedaży';'Dane sprzedaży'[Workers.SprzedażTowaru.Rozchód.Ilość]); // Here sum of Sold items

        FILTER(ALL('TMiesiące'[Nr miesiąca]);'TMiesiące'[Nr miesiąca]<=_aktualnyMiesiac);

        FILTER('Dane sprzedaży';'Dane sprzedaży'[Workers.SprzedażTowaru.OkresOperacji.Do].[Rok]=2024)

    )

 

RETURN _cumulativeSales

 

but it keeps calculating it for each month separately.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Fistachpl 

I create a sample table:

vyohuamsft_0-1718174117984.png

First, create a new column to show month number:

MonthNumber = MONTH('Table'[Date])

vyohuamsft_1-1718174203129.png

 

Then create a new measure and try to use the following dax:

Cumulative Sales = 
CALCULATE(
    SUM('Table'[Sales]),
    FILTER(
        ALLSELECTED('Table'),
        'Table'[MonthNumber] <= MAX('Table'[MonthNumber])
    )
)

 

Put this measure in table visual, here is my preview:

vyohuamsft_2-1718174320192.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @Fistachpl 

I create a sample table:

vyohuamsft_0-1718174117984.png

First, create a new column to show month number:

MonthNumber = MONTH('Table'[Date])

vyohuamsft_1-1718174203129.png

 

Then create a new measure and try to use the following dax:

Cumulative Sales = 
CALCULATE(
    SUM('Table'[Sales]),
    FILTER(
        ALLSELECTED('Table'),
        'Table'[MonthNumber] <= MAX('Table'[MonthNumber])
    )
)

 

Put this measure in table visual, here is my preview:

vyohuamsft_2-1718174320192.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

xifeng_L
Super User
Super User

Hi @Fistachpl 

 

I don't know your model and context, but you can try below measure.

 

Cumulative sale =
VAR _aktualnyMiesiac = SELECTEDVALUE('TMiesiące'[Nr miesiąca]) //Current month
VAR _cumulativeSales =
    CALCULATE(
        SUMX('Dane sprzedaży';'Dane sprzedaży'[Workers.SprzedażTowaru.Rozchód.Ilość]); // Here sum of Sold items
        FILTER(ALL('TMiesiące'[Nr miesiąca]);'TMiesiące'[Nr miesiąca]<=_aktualnyMiesiac);
        FILTER(ALL('Dane sprzedaży');'Dane sprzedaży'[Workers.SprzedażTowaru.OkresOperacji.Do].[Rok]=2024);
        ALL('TMiesiące')
    )
RETURN _cumulativeSales

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

Just one thing. When I do:

ALL('Dane sprzedaży')

it calculates the data for more that is selected in fragmentators. Should I Keepfilters()?

Because I have fragmentators for 'Dane sprzedaży'[Kategoria], 'Dane sprzedaży'[Subkategoria] and then it counts ok. But I also have a fragmentator for the Products and if I select one it stops working.

If I add: 

VAR _cumulativeSales =

    CALCULATE(

        SUMX('Dane sprzedaży';'Dane sprzedaży'[Workers.SprzedażTowaru.Rozchód.Ilość]);

        FILTER(ALL('TMiesiące'[Nr miesiąca]);'TMiesiące'[Nr miesiąca]<=_aktualnyMiesiac);

        FILTER(ALL('Dane sprzedaży');'Dane sprzedaży'[Workers.SprzedażTowaru.OkresOperacji.Do].[Rok]=YEAR(now()));

        FILTER(ALL('Dane sprzedaży');'Dane sprzedaży'[Nazwa] IN VALUES('Dane sprzedaży'[Nazwa]));

    )

it works - I just added filter to calculate only for selected Products (Dane sprzedaży [ Nazwa]) but it doesn't work good, at least not always. Is it good way to filter by all selected products? 

wrong calculations:

Bez tytułu.png
In third row we already have a mistake: 260 + 339 +260 should be 859 instead of 851

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.