Forum Discussion
CALCULATE returns blank values
Hi!
I have a simple measure but i can't get why it doesnt work.
For example i have table:
| Year | LSV |
| 2018 | 1235 |
| 2019 | 5432 |
| 2020 | 7653 |
So i need to show value by the previous year in a row. I made the following measure:
Is there ant chance to get it works?
Hi sugloevg
Measure has no real sense with just a [Year] in filter sentence
try
PREVLSV = var _curYear = MAX('Table'[Year]) RETURN CALCULATE(SUM('Table'[LSV]), FILTER(ALL('Table'), 'Table'[Year] = _curYear -1))
8 Replies
- AnonymousNot applicable
Hi az38
I have used your formula but what if I want to get the month breakdown? It's showing the total sum but I know it's because of the Calculate Sum but don't know How to get month breakdown- az38
Community Champion
Hi Anonymous
you can try SAMEPERIODLASTYEAR() function.
like
CALCULATE(SUM('Table'[LSV]), SAMEPERIODLASTYEAR('Table'[Date]))
- nandukrishnavs
Community Champion
Try this DAX measure
PREVLSV = VAR _Year = SELECTEDVALUE ( 'Table'[Year] ) RETURN CALCULATE ( SUM ( 'Table'[LSV] ), FILTER ( ALL ( 'Table'[Year] ), 'Table'[Year] = _Year - 1 ) )
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂 - edhans
Community Champion
Try this sugloevg
Prior Year = VAR PriorYear = MAX('Table'[Year]) - 1 VAR Result = SUMX( FILTER( ALL('Table'), 'Table'[Year] = PriorYear ), 'Table'[LSV] ) RETURN ResultIt gets the current year, then subtracts 1. Then the SUMX() only operates on prior year data from the table provided by FILTER().
- sugloevgFrequent Visitor
Thank you a lot, guys!
- Syndicate_Admin
Administrator
Try this @sugloevg
Prior Year = VAR PriorYear = MAX('Table'[Year]) - 1 VAR Result = SUMX( FILTER( ALL('Table'), 'Table'[Year] = PriorYear ), 'Table'[LSV] ) RETURN ResultGets the current year, and then subtracts 1. Then, the SUMX() only works on the previous year's data from the table provided by FILTER().
- Syndicate_Admin
Administrator
Try this @sugloevg
Prior Year = VAR PriorYear = MAX('Table'[Year]) - 1 VAR Result = SUMX( FILTER( ALL('Table'), 'Table'[Year] = PriorYear ), 'Table'[LSV] ) RETURN ResultGets the current year, and then subtracts 1. Then, the SUMX() only works on the previous year's data from the table provided by FILTER().