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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Yerlasdu95
New Member

PowerBi Desktop Table Dynamically Calculate Table values with filter

Hi Folks, 

 

Could you please help me with this issue?!

 

I have Column HourID in table. I need new column, which will calculate sum of this Column

f.e 1 = 1

2= 3 (1+2).

3 = 6 (1+2+3)

6 = 12 (1+2+3+6)

Yerlasdu95_0-1716497797892.png

 

It works. But, when I filter the table, it not calculate it again with filtered values:

Yerlasdu95_1-1716497888395.png

It should be: 2 =2; 4=6 (2+4)

Calculated Column Dax:

col = 
VAR CurrentHoursID = 'ERO Overtime Request'[HoursID]
RETURN
CALCULATE(
SUM('ERO Overtime Request'[Hours]),
FILTER(
ALL('ERO Overtime Request'),
'ERO Overtime Request'[HoursID] <= CurrentHoursID
)
)

 

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

The issue is that you're using a calculated column. Your filters cannot dynamically alter the values that are in a calculated column because these values are only evaluated when the report is refreshed - i.e you need to use a measure instead. 

 

Your existing DAX can be altered slightly to fit your problem - 

 

measure = 
var currentHrs = SELECTEDVALUE('ERO Overtime Request'[Hours])
return CALCULATE(SUM('ERO Overtime Request'[Hours]), FILTER(ALL('ERO Overtime Request'[Hours]), 'ERO Overtime Request'[Hours] <= currentHrs))

 

the only part that changed is that i will only remove the filter on hours, rather than the whole table, so that will allow the table to be filtered by other columns.

vicky__0-1716503582387.png

with the filter

vicky__1-1716503590809.png

without the filter

View solution in original post

2 REPLIES 2
vicky_
Super User
Super User

The issue is that you're using a calculated column. Your filters cannot dynamically alter the values that are in a calculated column because these values are only evaluated when the report is refreshed - i.e you need to use a measure instead. 

 

Your existing DAX can be altered slightly to fit your problem - 

 

measure = 
var currentHrs = SELECTEDVALUE('ERO Overtime Request'[Hours])
return CALCULATE(SUM('ERO Overtime Request'[Hours]), FILTER(ALL('ERO Overtime Request'[Hours]), 'ERO Overtime Request'[Hours] <= currentHrs))

 

the only part that changed is that i will only remove the filter on hours, rather than the whole table, so that will allow the table to be filtered by other columns.

vicky__0-1716503582387.png

with the filter

vicky__1-1716503590809.png

without the filter

hi @vicky_ 
Measure works with some corrections. Thank you

 

Cumulative Hours = 
CALCULATE(
SUM('ERO Overtime Request'[Hours]),
FILTER(
ALLSELECTED('ERO Overtime Request'),
'ERO Overtime Request'[HoursID] <= MAX('ERO Overtime Request'[HoursID])
)
)

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.