Forum Discussion
How get the last value on a given date
- Anonymous5 years ago
Hi Anonymous
I think you can add an index column in Power Query Editor.
My Sample:
Group all rows by DateKey column, then add an index column by custom column.
Expand all column in Custom and remove other columns.
Build a calendar table for slicer.
Calendar = CALENDARAUTO()Then build a measure filter and Remainder measure.
Filter = IF(MAX('Table'[DatePay])<=SELECTEDVALUE('Calendar'[Date]),1,0)Remainder = VAR _MaxDate = MAXX(FILTER(ALL('Table'),'Table'[Partner]=MAX('Table'[Partner])&&'Table'[DatePay]<=SELECTEDVALUE('Calendar'[Date])),'Table'[DatePay]) VAR _MaxIndex = MAXX(FILTER(ALL('Table'),'Table'[Partner]=MAX('Table'[Partner])&&'Table'[DatePay] = _MaxDate),'Table'[Rank]) RETURN IF(HASONEVALUE('Table'[DateKey]),SUM('Table'[RemDoc]),SUMX(FILTER(ALL('Table'),'Table'[Partner]=MAX('Table'[Partner])&&'Table'[DatePay] = _MaxDate&&'Table'[Rank]=_MaxIndex),'Table'[RemDoc]))Result is as below.
You can download the pbix file from this link: File
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous
I think you can add an index column in Power Query Editor.
My Sample:
Group all rows by DateKey column, then add an index column by custom column.
Expand all column in Custom and remove other columns.
Build a calendar table for slicer.
Calendar = CALENDARAUTO()
Then build a measure filter and Remainder measure.
Filter = IF(MAX('Table'[DatePay])<=SELECTEDVALUE('Calendar'[Date]),1,0)Remainder =
VAR _MaxDate = MAXX(FILTER(ALL('Table'),'Table'[Partner]=MAX('Table'[Partner])&&'Table'[DatePay]<=SELECTEDVALUE('Calendar'[Date])),'Table'[DatePay])
VAR _MaxIndex = MAXX(FILTER(ALL('Table'),'Table'[Partner]=MAX('Table'[Partner])&&'Table'[DatePay] = _MaxDate),'Table'[Rank])
RETURN
IF(HASONEVALUE('Table'[DateKey]),SUM('Table'[RemDoc]),SUMX(FILTER(ALL('Table'),'Table'[Partner]=MAX('Table'[Partner])&&'Table'[DatePay] = _MaxDate&&'Table'[Rank]=_MaxIndex),'Table'[RemDoc]))
Result is as below.
You can download the pbix file from this link: File
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.