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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RamiSomar
Frequent Visitor

Issue in using lastnonblankvalue with main categories & sub categories

My report contains a table (linked to calander table) with three columns (Date, First Code,Amount_FCY) and I'm using below mearuse to fill balnk cells with lastnonblank value : 

Bal_FCY =  var d = SELECTEDVALUE(Calendar_Table[Date]) return
0+CALCULATE(
LASTNONBLANKVALUE(Calendar_Table[Date],sum('Historical MT940'[Amount_FCY]))
,Calendar_Table[Date]<=d)

 

the measure works percectly on sub category level ("First Code" Level), but when it comes to Total Level the measure Ignores blank cells. for excample: on 19-Jun, for First Code =SABB 003 , Bal_FCY = 39.048M and for First Code = SHB 331, Bal_FCY= -157.50 , while the total Bal_FCY = -157.50. The correct Value supposed to be ( 39.048M + (-157.50)). The same issue for Grand Total which alway persenting Zero. 

Any idea how can I adjust my measure.

Thanks in Advance. 

 

Untitled.png

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@RamiSomar , Try if this can help

Bal_FCY = var d = SELECTEDVALUE(Calendar_Table[Date]) return
Sumx(Values(Calendar_Table[Date]), 0+CALCULATE(LASTNONBLANKVALUE(Calendar_Table[Date],sum('Historical MT940'[Amount_FCY]))
,Calendar_Table[Date]<=d))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@RamiSomar , Try if this can help

Bal_FCY = var d = SELECTEDVALUE(Calendar_Table[Date]) return
Sumx(Values(Calendar_Table[Date]), 0+CALCULATE(LASTNONBLANKVALUE(Calendar_Table[Date],sum('Historical MT940'[Amount_FCY]))
,Calendar_Table[Date]<=d))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
lbendlin
Super User
Super User

Note that the measure uses SELECTEDVALUE() - that is not something that you have on the subtotals or totals filter context.  Depending on your situation you can

 

- use Min or Max instead

- question your need for actually having a total in that scenario

- write another measure just for the subtotals and totals

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.