Forum Discussion
Variance between current year and last year in columns
- 2 years ago
There probably is a way to do that. However, typically, the "Sales Amt" is calculated per a category of sorts. For example, "Sales Amt", per salesperson; store; region; or even date. Does that make sense? If you truly just want "Sales Amt", you could probably do something along the lines of:
ADDCOLUMNS ( SUMMARIZE ( SalesTable, [CY], [LY], [Variance] ), "Sales Amt", "Sales Amt" )I would need a better understanding of the data to build that DAX for you.
Lastly, if my response was helpful, marking it as a solution would be greatly appreciatedðŸ¤
No problem! I would recommend building 3 seperate measures:
Measure #1: Current Year
CY = TOTALYTD([SALES],'DateTable'[Dates])
This calculates the total sales, year to date. The 'DateTable'[Date] refers to the table you have your dates saved in
Measure #2: Last Year
LY = CALCULATE([CY],DATEADD(LASTDATE('DateTable'[Date]),-1,YEAR))
This calculates Measure #1, but for the previous year
Measure #3: Variance
Variance = [CY]-[LY]
---
Alternatively, you can do this all in a single measure with Variables:
Variance =
VAR _CY = TOTALYTD([SALES],'DateTable'[Dates])
VAR _LY = CALCULATE(_CY,DATEADD(LASTDATE('DateTable'[Date]),-1,YEAR))
RETURN
_CY - _LY
I hope this helps!
Thanks ExcelMonke that helps ! I get the values correctly that way.
But is there a way to show the "Sales Amt" label in the rows in the cross table ?
Thanks !
- ExcelMonke2 years ago
Impactful Individual
There probably is a way to do that. However, typically, the "Sales Amt" is calculated per a category of sorts. For example, "Sales Amt", per salesperson; store; region; or even date. Does that make sense? If you truly just want "Sales Amt", you could probably do something along the lines of:
ADDCOLUMNS ( SUMMARIZE ( SalesTable, [CY], [LY], [Variance] ), "Sales Amt", "Sales Amt" )I would need a better understanding of the data to build that DAX for you.
Lastly, if my response was helpful, marking it as a solution would be greatly appreciatedðŸ¤- nedpbi2 years ago
Helper I
Thanks ExcelMonke, this pointed me in the right direction !