Forum Discussion
Sum previous year
Hi,
that's my graph:
With the blue line (that's a simply distinct count) i need to sum the previous year to the current year.
So, it will become:
2014: 819
2015: 2412 + (819)
2016: 1702 + (2412 + 819)
....
How can i achieve this?
Thanks for help
Anonymous
try a measure
Measure = CALCULATE(SUM('Table'[Codici]),FILTER(ALL('Table'),'Table'[Year]<=MAX('Table'[Year])))
12 Replies
- amitchandakSuper User
If you have date dimension, you can try datesytd
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31")) Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31")) Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31")) Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31")) Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year)) 2 Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-2,Year))To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin- AnonymousNot applicable
How would you go about this if "Sales[Sales Amount]" was a measure?
- AnonymousNot applicable
Really useful and concise YTD measures, thank you.
- az38Community Champion
Hi Anonymous
If "Codici" are exist in both 2019 and 2018 years it should be calculated as 1 or as 2?
- AnonymousNot applicable
Hi,
it should be count as 2!
Thanks
- az38Community Champion
Anonymous
try a measure
Measure = CALCULATE(SUM('Table'[Codici]),FILTER(ALL('Table'),'Table'[Year]<=MAX('Table'[Year])))