Forum Discussion
YTD Context in Matrix
- Anonymous5 years ago
Hi asebes ,
You can create a measure as below and apply a relative date slicer, please find the details in the attachment.
Measure = VAR _curdate = SELECTEDVALUE ( 'Table'[date] ) RETURN CALCULATE ( SUM ( 'Table'[data] ), FILTER ( ALL ( 'Table' ), 'Table'[date] >= DATE ( YEAR ( _curdate ), 1, 1 ) && 'Table'[date] <= EOMONTH ( _curdate, 0 ) ) )Best Regards
asebes , For YTD you can use measure like this with date table
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Now for 6 months the best that you use a relative date filter. https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range
Or use an independent date table to select date range : https://www.youtube.com/watch?v=duMSovyosXE
But won't that measure be filtered on the month's in the column header and only give me that month's respective data?
What I need, for example, if the header month is Dec-20 then I need a sum of the transactions from 1/1/20 through 12/31/20. If the header is Feb-21, then would need a sum of the transactions from 1/1/21 through 2/28/21.
Hope that makes sense, thanks!