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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dbrandone
Helper IV
Helper IV

Last Month Calculations not functioning

Hey everyone,

 

I have the below measure that I am trying to calculate, but I cannot figure out why the dates between section is not filtering the data. The result is showing "Blank", but according to the data in the table view, I should have hundreds. I checked the relationships and the column formats and they are set correctly to date/time. 

 

Items sold Last Month =
                VAR vToday =
                         TODAY ()
                VAR vEndDate =
                         EOMONTH ( vToday, -1 )
                VAR vStartDate =
                         EOMONTH ( vToday, -2 ) + 1
                VAR vResult =
                         CALCULATE(
                                     COUNT(vSales[ItemSold]),
                                                    DATESBETWEEN('Calendar'[Date].[Date], vStartDate, vEndDate)
)
Return
       vResult
 
In our database, each item sold makes its own row with corresponding information. If a person buys 4 items, then 4 rows are created in the database.
 
As I have been researching this issue and troubleshooting, I keep thinking that there is something going on with my date table or the references to the date table. When I took a basic count calculation of a table and put the count into a card and then made another card with a TotalYTD measure in it, the numbers are identical even though I have 4-5 years worth of data. There is no way they should be similar numbers. Can my date table be causing this issue? All relationships to tables are active.
1 ACCEPTED SOLUTION

Hi @dbrandone ,

 

Please check the relationship between your calendar table and vsales table. It should be one to many active relationship.

 

You can also use the following measure:

 

Items sold Last Month = 
                VAR vToday =
                         TODAY ()
                VAR vEndDate =
                         EOMONTH ( vToday, -1 )
              
                VAR vResult =
                         CALCULATE(
                                     COUNT(vSales[ItemSold]),
                                                    DATESINPERIOD('Calendar'[Date], vStartDate, 1,MONTH)
)
Return
       vResult

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

5 REPLIES 5
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @dbrandone ,

 

the 'Calendar'[Date].[Date] looks wrong, it should be 'Calendar'[Date].

Please check if you have marked your Calendar table as a date table.

 

https://www.sqlbi.com/articles/mark-as-date-table/

 

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Hi @mwegener ,

 

Yeah, I noticed that. I tried both 'Calendar[Date]' and 'Calendar[Date].[Date]' and both are having issues. I was trying anything I could at that point. I think I tried the .[Date] at the end since intellisense was offering it. I checked and it is marked as the date table. 

Hi @dbrandone ,

 

Please check the relationship between your calendar table and vsales table. It should be one to many active relationship.

 

You can also use the following measure:

 

Items sold Last Month = 
                VAR vToday =
                         TODAY ()
                VAR vEndDate =
                         EOMONTH ( vToday, -1 )
              
                VAR vResult =
                         CALCULATE(
                                     COUNT(vSales[ItemSold]),
                                                    DATESINPERIOD('Calendar'[Date], vStartDate, 1,MONTH)
)
Return
       vResult

 

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

 

Best Regards,

Dedmon Dai

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @dbrandone ,

it works in my sample file.

(see attached file)

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


mwegener
Most Valuable Professional
Most Valuable Professional

Hi @dbrandone ,

 

can you provide a sample file?

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors