Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi all.
I have table:
that false. Would like to see the remainder from 12885,82625 as of 04.12.2019
More samples as I want to see:
I try next queries, but nothing correct worked:
Remainder:=
var a = CALCULATE(LASTNONBLANK('Table1'[RemDoc], 1),
FILTER(ALL('Date'),'Date'[DateKey] <= MAX('Table1'[DateKey])))
var b = IF((a<=0),0)
return a
******
Remainder:=
var suma = CALCULATE (SUM('Table1'[RemDoc]),
FILTER (ALL('Date'),'Date'[DateKey] <= MAX('Table1'[DateKey])))
var rem = IF((suma<0),0,suma)
return rem
******
Остаток:=
SUMX (VALUES ('Table1'[Partner]),
VAR LastBalanceDate = CALCULATE ( MAX ( Table1'[DateKey] ) )
RETURN
CALCULATE (
SUM ('Table1'[RemDoc]),
'Date'[DateKey] >= LastBalanceDate))
****
How to achieve the desired result?
Thanks for your helps.
@Anonymous
What you have tried is running total, to return latest date value, try create this measure using lastdate():
@Anonymous
can't calculate the lastdate()
@Anonymous
What do you mean you can't? Is there any error message?
You use calcuate() to call out the [Remdoc] column value, and filter to the lastdate of the given date.
Paul
@Anonymous can you help me?
@Anonymous
Yes, error. Did as in your exemple.
remember you need to control the filter context for Calculate(), otherwise it will only calculate it for the "current row"
Don't use functions inside CALCULATE() filters. They get impacted by the context transition. Define your filters as variables before using them in CALCULATE().
Like you do it in your last example.
@lbendlin
So:
VAR LastBalanceDate = CALCULATE(MAX( 'Table1'[DateKey]))
RETURN
CALCULATE(
LASTNONBLANK('Table1[RemDoc],SUM('Table1'[RemDoc])),
'Date'[DateKey] <= LastBalanceDate)
Or so:
LASTNONBLANK(VALUES ('Table1'[RemDoc]),
VAR LastBalanceDate = CALCULATE(MAX( 'Table1'[DateKey]))
RETURN
CALCULATE(
SUM ('Table1'[RemDoc]),
'Date'[DateKey] <= LastBalanceDate))
both options don't work
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.