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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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))

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))

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
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors