Forum Discussion
Monthly delta measures/calculated column
- 4 years ago
Anonymous Create a measure for Dec 2021, then subtract that from [Total Sales] and put it in a visual by month Year:
Total Sales = SUM ( Sales[Sales] )
Dec 2021 Sales = CALCULATE ( [Total Sales] , Date[Month Year] = "Dec 2021" )
Diff = [Total Sales] - [Dec 2021 Sales]
Thanks AllisonKennedy for the response,
I've tried your solution,
The, Date[Month Year] in Dec 2021 Sales = CALCULATE ( [Total Sales] , Date[Month Year] = "December 2021" ) is from date table right?
I did all the step you shows in creating the three measure.
But when I visualize the ID, Month Year, Sales Delta/Diff this error happens, it says about this measure(Dec 2021 Sales) got an error because we are comparing date with text.
I think it is because this column Date[Month Year] is date type but when we filtering we put, Date[Month Year] = "December 2021" make the value compared to is a text.
do you know how could we fix this?
Anonymous Yes, the Date[Month Year] should be from your date table and should be a new column, not the Date column. This column should be text that groups the Month and Year from your Date. You can add this in Power Query. Select the Month name column and Year column using the Ctrl key, then Click the Add Column tab > Merge Columns. Use Space as a separator. Name this column Month Year. Then use it in the measure. It will be text data type.