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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
dosania
Helper II
Helper II

Month on Month figures only showing when there are 31 days in a month

Hi,

 

I'm trying to calculate month on month change in some of my finance figures, and am writing a calcaultion in DAX to do this.

My SQL gives me the balance on the last day of the month for each month.

 

The DAX I have written to give me the Balance for Last month is below;

Balance LM = calculate(sum('Balance'[Amount]),dateadd('Balance'[Timekey],-1,month)

This formula only gives me the balance for the previous month, only if there are 31 days in the month. 

Below is an example of what is happening.

 

PBI Date Error.PNG

 

When I re-write the formula with the [date] reference as below, it gives me the same balance for this month and last month;

Balance LM = calculate(sum('Balance'[Amount]),dateadd('Balance'[Timekey].[Date],-1,month)

 

Any help on how to solve this would be much appreciated!

 

Thanks,

Anish

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@dosania as a best practice you should add date dimension in your model and perform time intelligence calculation based on that table instead of your transactional table. To add a simple date dimension, check one of my blog post here, and in your measure change balance[Date] to DateDimension[Date].

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
v-janeyg-msft
Community Support
Community Support

Hi, @dosania 

 

It’s my pleasure to answer for you.

According to your description, If you want to use the ‘dateadd’ function, then your date column must be a continuous date. But it seems that your date column has only one day per month, so you don’t need to use time intelligence function.

You can try like this:

Amount Last Month = 
SUMX(FILTER(ALL('Table'),[Date]=EOMONTH(SELECTEDVALUE('Table'[Date]),-1)),[Amount])

4.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

parry2k
Super User
Super User

@dosania you should mark your date table as a date table, it is in my blog post on how to do it, and don't use DateTable[Date].[Date], it should be DateTable[Date]



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@dosania as a best practice you should add date dimension in your model and perform time intelligence calculation based on that table instead of your transactional table. To add a simple date dimension, check one of my blog post here, and in your measure change balance[Date] to DateDimension[Date].

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks @parry2k. I have a date dimension in my table and have tried using this in the dax.

I've tried using the below;

Balance LM = calculate(sum('Balance'[Amount]),dateadd('DateTable'[Date],-1,month)

 

This gives me the following error message, 'MdxScript(Model) (97,76) Calculation error in measure 'Calculations'[Balance LM]: Function 'DATEADD' expects a contiguous selection when the date column comes from a table on the 1-side of a bi-directional relationship.'

 

When I try, Balance LM = calculate(sum('Balance'[Amount]),dateadd('DateTable'[Date].[date],-1,month),

it gives me the same balance for this month and last month.

 

Any thoughts would be great

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors