Forum Discussion
Filter amounts by year
- 5 years ago
Hi Anonymous ,
There is option to create disconnected table.
Example: create new table which will have values 2017, 2018, 2019. This table must not have any connection to existing table where you have measures.
In slicer use Year from this new disconnected table.
Now create these 2 measures:Current Year =var _currentYear = SELECTEDVALUE('Year'[Year])RETURN CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[ImpYear]=_currentYear))Past Year =var _previousYear = SELECTEDVALUE('Year'[Year])-1RETURN CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[ImpYear]=_previousYear))Regards,
Nemanja Andic
Hi Anonymous , attached power bi file with both scenarios.
One scenario (on the right) which is simpler, it doesn't use disconnected table so everything is based on original (regular) table.
Second scenario (on the left) if you are using disconnected table.
Regards,
Nemanja Andic
- Anonymous5 years agoNot applicable
nandic I want a Last YTD total which is different from Last Year total. So in order to do that, I tried this query which is not giving any value:
Last YTD =
var _cy = MAX('Table'[ImpYear]) RETURN CALCULATE([regular_Current Year], MONTH(Table[ReportedDate])<=MONTH(TODAY())-1, 'Table'[ImpYear]=_cy)+0Or may be is there any other efficient way to find the Last YTD?- nandic5 years ago
Resident Rockstar
Anonymous , attached new version of the file, i missed that you wrote last year "ytd".
New version of the file is focused on regular measures (i deleted disconnected table and measures).Past YTD =var _currentYear = MAX('Table'[ImpYear])RETURNCALCULATE([Current Year],'Table'[ImpYear]=_currentYear-1, 'Table'[Day of Year]<=DAY(TODAY()))For this purpose i added new column in table which calculates day number of the year.Day of Year =DATEDIFF ( DATE ( YEAR ( 'Table'[ReportedDate] ), 1, 1 ), 'Table'[ReportedDate], DAY ) + 1Also, i added more data in data source so that you can check it.Regards,
Nemanja Andic- Anonymous5 years agoNot applicable
nandic Since I have data for new months loaded, it seems that the Past YTD does not calculate the right amount. For example, currently it's March and ideally the formula should have added the amounts for the month of January, February and March of previous year, however, it only displays the amount for January. Could you please help me fix this?