Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
hello
i want to sum the last non blank values from the three columns as figured in below pictures. green column
i tried this formula, it gave me the the result in column TOTA MP PLAN
thanks
Solved! Go to Solution.
Ah, so I misunderstood what you were trying to achieve. So you need the LastNonBlank to fill the gaps, but you want to keept the blank after the last occurrence. I think you could simply add an IF, like below.
MP Plan =
VAR cal_type = "Plan"
VAR cal_item = "ManPower"
VAR last_date = MAX ( CalendarData[DateID])
RETURN
SUMX (
VALUES ( SITE_MOC_ID[MOC_ID] ),
IF(CALCULATE(MAX(Schedules_Progress[Date]),
ALL(CalendarData)
Schedules_Progress[Item] = cal_item,
Schedules_Progress[Type] = cal_type
) >= last_date,
CALCULATE (
LASTNONBLANKVALUE (
CalendarData[DateID],
MAX ( Schedules_Progress[Value] )
),
ALL ( CalendarData ),
CalendarData[DateID] <= last_date,
Schedules_Progress[Item] = cal_item,
Schedules_Progress[Type] = cal_type
)
)
)
(assuming Schedules_Progress[Date] is linked to CalendarData[DateID])
I think you might be overcomplicating things, try this:
MP Plan =
VAR cal_type = "Plan"
VAR cal_item = "ManPower"
VAR last_date = MAX ( CalendarData[DateID])
RETURN
SUMX (
VALUES ( SITE_MOC_ID[MOC_ID] ),
CALCULATE (
LASTNONBLANKVALUE (
CalendarData[DateID],
MAX ( Schedules_Progress[Value] )
),
ALL ( CalendarData ),
CalendarData[DateID] <= last_date,
Schedules_Progress[Item] = cal_item,
Schedules_Progress[Type] = cal_type
)
)
thanks @sjoerdvn
your formulat is the logical one.
but my issue here is that i dont want the calculation to go beyond the last value for each column.
so i want to calculate the sum of last nonbank value since there a value after (just to cover the gap between values)
Ah, so I misunderstood what you were trying to achieve. So you need the LastNonBlank to fill the gaps, but you want to keept the blank after the last occurrence. I think you could simply add an IF, like below.
MP Plan =
VAR cal_type = "Plan"
VAR cal_item = "ManPower"
VAR last_date = MAX ( CalendarData[DateID])
RETURN
SUMX (
VALUES ( SITE_MOC_ID[MOC_ID] ),
IF(CALCULATE(MAX(Schedules_Progress[Date]),
ALL(CalendarData)
Schedules_Progress[Item] = cal_item,
Schedules_Progress[Type] = cal_type
) >= last_date,
CALCULATE (
LASTNONBLANKVALUE (
CalendarData[DateID],
MAX ( Schedules_Progress[Value] )
),
ALL ( CalendarData ),
CalendarData[DateID] <= last_date,
Schedules_Progress[Item] = cal_item,
Schedules_Progress[Type] = cal_type
)
)
)
(assuming Schedules_Progress[Date] is linked to CalendarData[DateID])
so smart,
just , if you can explain it to me so i understand the logic behind it , and understand more DAX, i will appreciate it.
@Abdullah_Dax Create a measure to get the last non-blank value for each column.
DAX
LastNonBlankValue_Column1 =
CALCULATE(
LASTNONBLANKVALUE(
Schedules_Progress[Date],
MAX(Schedules_Progress[Column1])
)
)
LastNonBlankValue_Column2 =
CALCULATE(
LASTNONBLANKVALUE(
Schedules_Progress[Date],
MAX(Schedules_Progress[Column2])
)
)
LastNonBlankValue_Column3 =
CALCULATE(
LASTNONBLANKVALUE(
Schedules_Progress[Date],
MAX(Schedules_Progress[Column3])
)
)
SumLastNonBlankValues =
[LastNonBlankValue_Column1] + [LastNonBlankValue_Column2] + [LastNonBlankValue_Column3]
Proud to be a Super User! |
|