Forum Discussion
Dynamically filter last row per item
- 3 years ago
You could try
Sum of last rows = VAR ChosenDate = MAX ( 'Date'[Date] ) VAR SummaryTable = CALCULATETABLE ( INDEX ( 1, 'Fact booking', ORDERBY ( 'Fact booking'[Last modified date], DESC ), PARTITIONBY ( 'Fact booking'[Sales ID] ) ), 'Date'[Date] <= ChosenDate ) VAR Result = SUMX ( SummaryTable, 'Fact booking'[Sales value] ) RETURN ResultThis makes a few assumptions. Firstly that your date table is linked to your fact table on the last modified date. Secondly, you will need a unique identifier for each row in fact booking. If you don't have one naturally you can add an index column using power query. Make sure that the unique column is marked as the key column in the modelling view, that will stop INDEX complaining that the table may have duplicates.
You could try
Sum of last rows =
VAR ChosenDate =
MAX ( 'Date'[Date] )
VAR SummaryTable =
CALCULATETABLE (
INDEX (
1,
'Fact booking',
ORDERBY ( 'Fact booking'[Last modified date], DESC ),
PARTITIONBY ( 'Fact booking'[Sales ID] )
),
'Date'[Date] <= ChosenDate
)
VAR Result =
SUMX ( SummaryTable, 'Fact booking'[Sales value] )
RETURN
Result
This makes a few assumptions. Firstly that your date table is linked to your fact table on the last modified date. Secondly, you will need a unique identifier for each row in fact booking. If you don't have one naturally you can add an index column using power query. Make sure that the unique column is marked as the key column in the modelling view, that will stop INDEX complaining that the table may have duplicates.