Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Monthly delta measures/calculated column

Hi community,


Need help to solve this.
I have this data.

DNameMonthSales
1JoeDecember 20213000
1JoeJanuary 20225000
1JoeFebruary 20225000
2ImranDecember 20212000
2ImranJanuary 20228000
2ImranFebruary 20227000
3NatalieDecember 20216000
3NatalieJanuary 20229000
3NatalieFebruary 20223000

 

How can i have a calculate column or a measure of monthly delta which is each month sales minus december 2021 sales. The december act as a baseline.

 

Thanks.

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@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]


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

7 REPLIES 7
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure :

Measure = 
var _per= CALCULATE(SUM([Sales]),FILTER(ALL('Table'),EOMONTH([Month],0)=EOMONTH(MAX([Month]),0)))
var _12last=CALCULATE(SUM([Sales]),FILTER(ALL('Table'),[Month].[Year]=2021&&[Month].[MonthNo]=12))
return _per-_12last

Or a column.

Column = 
var _per= CALCULATE(SUM([Sales]),FILTER('Table',EOMONTH([Month],0)=EOMONTH(EARLIER([Month]),0)))
var _12last=CALCULATE(SUM([Sales]),FILTER('Table',[Month].[Year]=2021&&[Month].[MonthNo]=12))
return _per-_12last

The final output is shown below:

vyalanwumsft_0-1646016964372.pngvyalanwumsft_1-1646016970019.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yingjl why have you accepted @v-yalanwu-msft 's solution please? I posted a very similar solution 4 days before @v-yalanwu-msft  and I purposefully did NOT include a way to create a calculated column, as that is not the best practice solution and will make the data model larger than it needs to be. 

 

From my knowledge, my solution is simpler and more efficient, but I'm happy to learn, so please curious why you chose @v-yalanwu-msft 's solution. Thanks!


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Tried these:

 

Total Sales = SUM ( Sales[Sales] )

 

Dec 2021 Sales = CALCULATE ( [Total Sales] , Date[Month Year] = "Dec 2021" )

 

Diff = [Total Sales] - [Dec 2021 Sales]

 

But the Dec 2021 Sale measure,  return blank for all.

@Anonymous  What does your Dim Date table look like? You must have a Text field for Month Year that exactly says "Dec 2021", if it says anything different this will not work and you'll have to change to what your date table looks like. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

@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]


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

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.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.