Hi
I'm trying to create a running total to be evaluated for a specific period. The measure is applied in a stacked chart which has YYYYMM as x axis where continous x axis is disabled. The formula is based on a date table and a transaction table. It works until I apply a legend, or categorization, by location from the transaction table. Then the date table is disregarded and powerbi chooses the date column in the transaction table as a date table, which is unfortunate as it's incomplete.
E.g. filtering for all dates from last date in november - 14 days suddenly becomes last transaction date for location -14 days once location is added as a filter.
Does anyone have any idea why this happens and what I can do with it?
E.g.
EVALUATE ROW ( "gfdsfg",
CALCULATE ( CALCULATE ( LASTDATE ( L_Datetable[DateKey] ), FILTER ( ALL ( L_Datetable ), L_Datetable[DateKey]> ( MAX ( L_Datetable[DateKey] ) - 14 )&& L_Datetable[DateKey] <= MAX ( L_Datetable[DateKey] ) ) ), L_Datetable[YearMonth] = 201611, S_BSAK[Location] = "1" ) )
yields the last transaction for location 1, 01.11.2016, (DD.MM.YYYY) where the outer calculate represent the filter applied in the chart as legend. It actually uses the daterange 01.11.2016 to 01.11.2016-14d instead of using the asked 15.11.2016 to 15.11.2016-14d range. Hence it ends up with 01.11.2016
While mashing it all in one calculate works as expected:
EVALUATE ROW ( "gfdsfg"; CALCULATE ( LASTDATE ( L_Datetable[DateKey] ); FILTER ( ALL ( L_Datetable ); L_Datetable[DateKey]> ( MAX ( L_Datetable[DateKey] ) - 14 )&& L_Datetable[DateKey] <= MAX ( L_Datetable[DateKey] ) ) ; L_Datetable[YearMonth] = 201611; S_BSAK[Location] = "1") )
Which returns blank (i.e. no transactions as the max date in the date table is 15.11.2016-14d=01.11.2016, and hence no transactions fits as the first one is 01.11.2016, and the filter is bigger than)
Any tips and tricks are much appreciated!