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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Elvi_well
Frequent Visitor

Running total with two categories (one of them is dynamical)

Hi!

I’m trying to count running total of marks by studyyear and subject. When I count total it works.

Elvi_well_0-1730915037372.png

Elvi_well_2-1730915083469.png

Filter and legend don’t work. As example in the picture below Mark B never follow Year 2 and 3, mark C does not appear Year 2, total amount becomes wrong.

Elvi_well_3-1730915240024.png

The same for subjects, Math1 is not shown year 2 and 3.

Elvi_well_4-1730915289676.png

When I choose math1 in the filter, year2 and 3 disappear at all.

Elvi_well_5-1730915358456.png

 

If I expect that mark A for math1 counts year 1,2,3, how could I change my DAX?
Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from FreemanZ.


Hi @Elvi_well ,

 

Some categories are not displayed because the corresponding data does not exist for that year, so you can fill in the missing data for the year and use the column as a legend.


I create simple test data:

vlinhuizhmsft_0-1730961787642.png

 

Please try the following steps:
1.Fill in the missing "mark" in each year.

vlinhuizhmsft_1-1730961839076.png

2.Then create the combination of year and course name as shown here.

vlinhuizhmsft_2-1730961964016.png

3.In Power Query Editor, create a merged table:

vlinhuizhmsft_3-1730962075273.png

vlinhuizhmsft_4-1730962144450.png

vlinhuizhmsft_5-1730962224702.png

 

4.Create a new measure:

Measure2 = CALCULATE(COUNT('4Merge'[Ismark]),'4Merge'[Year]<=MAX('4Merge'[Year]))

 

5.Create visuals:

vlinhuizhmsft_6-1730962444410.png

vlinhuizhmsft_7-1730962464295.png

 

Best Regards,
Zhu

 

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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks for the reply from FreemanZ.


Hi @Elvi_well ,

 

Some categories are not displayed because the corresponding data does not exist for that year, so you can fill in the missing data for the year and use the column as a legend.


I create simple test data:

vlinhuizhmsft_0-1730961787642.png

 

Please try the following steps:
1.Fill in the missing "mark" in each year.

vlinhuizhmsft_1-1730961839076.png

2.Then create the combination of year and course name as shown here.

vlinhuizhmsft_2-1730961964016.png

3.In Power Query Editor, create a merged table:

vlinhuizhmsft_3-1730962075273.png

vlinhuizhmsft_4-1730962144450.png

vlinhuizhmsft_5-1730962224702.png

 

4.Create a new measure:

Measure2 = CALCULATE(COUNT('4Merge'[Ismark]),'4Merge'[Year]<=MAX('4Merge'[Year]))

 

5.Create visuals:

vlinhuizhmsft_6-1730962444410.png

vlinhuizhmsft_7-1730962464295.png

 

Best Regards,
Zhu

 

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

Hello!
thanks a lot for your answer!
I just wanted to confirm one thing. I use a playground for this question, in reality I have a big dataset with many years, so if I would solve the problem with backend measures it could impact the size of the dataset/redundance if I need a special table just for this. Is it absolutly impossible to solve with help of DAX, something to remove filtercontext? or if there are no corresponding data other years DAX can't help in principle? 

FreemanZ
Super User
Super User

hi @Elvi_well ,

 

could you paste the corresponding data table?

It is simulated, just for the problems description. 

Elvi_well_0-1730980642387.png

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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