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
KEO46
Helper I
Helper I

Calculate Previous Months Total

I need to create a measure that documents the previouse months total number of exceptions that were submitted so I can display it in a month on month report.  The field for the exceptions, "Combine Exception'[TargetObjectId" is a text so I used the calculate count function.  I created a calendar table with a relationship to the date field, "Combine Exception'[CreatedDate ]".  But when I add the created date to the formula I am getting an error, "Function "DATEADD' expects a contiguous selection when the date column is not unique, has gaps or it contains time portion."

 

I have never used a calendar table before so I am not sure if the formual that I have is correct.  Below is the formula that I used for my PrevMonth field. 

 

PreMonth = CALCULATE(COUNT('Combine Exception'[TargetObjectId ]),DATEADD('Combine Exception'[CreatedDate ],-1,MONTH))
 
If you know of a video that I can watch for a first time user of a calendar table that will help me to create the measure please share it with me.
 
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@KEO46 , Always used a date table, marked as date tbale joined 1- Many (Single Directional) with your table

 

PreMonth = CALCULATE(COUNT('Combine Exception'[TargetObjectId ]),DATEADD('Date'[Date],-1,MONTH))

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
KEO46
Helper I
Helper I

Yes this was extreamly helpful.  

amitchandak
Super User
Super User

@KEO46 , Always used a date table, marked as date tbale joined 1- Many (Single Directional) with your table

 

PreMonth = CALCULATE(COUNT('Combine Exception'[TargetObjectId ]),DATEADD('Date'[Date],-1,MONTH))

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.