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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
newbie9292
Helper II
Helper II

Help with DAX for cummulative data

I want to get the running total or cummulative total in the "KUM_LY_AE" column like in "KUM_AE" column but only getting summarized data. This the dax query I am using : 

KUM_LY_AE = CALCULATE (SUM(AE_2020[AuftrEing]),FILTER (ALLSELECTED(Date_dim[Date]),Date_dim[Date] <= MAX (Date_dim[Date])))
newbie9292_0-1627132456741.png

I have 2020 data and current year data in different tables and connected these tables with a calendar table.

Please help.

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @newbie9292 ,

 

Please use the following measure:

 

KUM_LY_AE = CALCULATE (SUM(AE_2020[AuftrEing]),FILTER (ALLSELECTED(Date_dim[Date]),Date_dim[Date] <= MAX (Date_dim[Date])&&MONTH(Date_dim[Date])<=MONTH(MAX (Date_dim[Date]))))

 

It works well based on my test data. 

 

You can also refer to my test pbix.

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

18 REPLIES 18
v-deddai1-msft
Community Support
Community Support

Hi @newbie9292 ,

 

Please use the following measure:

 

KUM_LY_AE = CALCULATE (SUM(AE_2020[AuftrEing]),FILTER (ALLSELECTED(Date_dim[Date]),Date_dim[Date] <= MAX (Date_dim[Date])&&MONTH(Date_dim[Date])<=MONTH(MAX (Date_dim[Date]))))

 

It works well based on my test data. 

 

You can also refer to my test pbix.

 

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

 

Best Regards,

Dedmon Dai

aj1973
Community Champion
Community Champion

Hi @newbie9292 

This column here, from which Table is it added to the visual?

aj1973_0-1627133159196.png

And how the Dim_Date and AE_2020 tables are connected?

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hello Amine,

 

Thanks for your reply.

This is how my model looks like : 

newbie9292_0-1627209344361.png

 

This is how the tables are connected : 

newbie9292_1-1627209411694.png

 

You need to set the data type for you date column in the fact tables to "date". It looks like they are set to type "whole number".

also make sure the fields in your visuals and slicer all come from the date table.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hello @PaulDBrown ,


Thanks for your reply. Yes the columns are in date format now and the slicers are coming from the date table but still the issue remains.

Hi @newbie9292 

Can I see how you formated the Date column in AE_2020?

Also please Copy paste the visual into another page and show us.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hello @aj1973 ,

This how my formatted date column looks like:

newbie9292_1-1627217321467.png

 

This is the visual :

newbie9292_0-1627217269632.png

When I select 2020 in the slicer, the cummulated value is shown correctly : 

newbie9292_2-1627217403017.png

But when I select 2020 and 2021 in the slicer, it messes up the cummulated data for 2020 only : 

newbie9292_3-1627217462642.png

 

 

you need to add the year field from your date table to the visuals and then drill down to month level





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Well that's normal because the column Month Name is cumulating the sum for January 2020 and January 2021 (it's an example), meaning your formula is not calculating it right upon the filters.

 

Maybe use Month Name_Year should solve the issue

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

So shall I create a new column with month name and year like Month_name + Year in the date table?

Yes,

Do the test if you want by replacing the column Month name by column Date in the Matrix, and then Use date hierarchy to only select Month and Year into your Matrix

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

I don't see a date heirarchy in the date table : 

newbie9292_0-1627218729966.png

 

It looks like you date column is not formated. It should look like this

aj1973_0-1627219009484.png

 

Or add Date to rows and then delete Quarter and Day

aj1973_1-1627219215947.png

 

 

Or add a new field MMM-YY, if it's easier for you.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

It looks like this : 

newbie9292_0-1627219411829.png

Do I need to change the DAX query : 

Kum_AE = CALCULATE (SUM(AE_Weekly[AuftrEing]),FILTER (ALLSELECTED(Date_dim[Date]),Date_dim[Date] <= MAX (Date_dim[Date])))

?
 

Why? what's wrong with what you see?

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

This my expected output : 

newbie9292_0-1627220288015.png

The only part wrong in this one is the KUM_LY_AE which should show the cummulative data per month.

@aj1973 

I am using this DAX query to calculate the cummulative or running total for the year 2020 : 

KUM_LY_AE = CALCULATE (SUM(Combined[AuftrEing]),FILTER (ALLSELECTED(Date_dim[Date]),YEAR(Date_dim[Date])=2020 && Date_dim[Date] <= MAX (Date_dim[Date])))
But it is not working. 😞

Hey @newbie9292 

Try something like this

aj1973_0-1627300069234.png

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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