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
chahineatallah
Helper III
Helper III

Date calculations in dax without using time intelligence

hello powerbi/power pivot community

 

Am practicing custom date functions like writing my own date functions rather than builtin, so i have a question regarding previous month calculations, I wrote the below formula for previous month, so below formula worked

 

CALCULATE([Total sales],FILTER(ALL('Calendar'),'Calendar'[Date]>=EOMONTH(MAX('Calendar'[Date]),-2)+1 && 'Calendar'[Date]<=EOMONTH(MAX('Calendar'[Date]),-1)))

 

my question why when i write below without MAX function, i get blank , as i understand Calendar[Date] should take filter context which i have in my table (for example year 2003 and january),

CALCULATE([Total sales],FILTER(ALL('Calendar'),'Calendar'[Date]>=EOMONTH('Calendar'[Date],-2)+1 && 'Calendar'[Date]<=EOMONTH('Calendar'[Date],-1)))

am i missing something/misunderstanding? Thanks

below is a snapshot for easy reference

date.jpg

1 REPLY 1
JW_van_Holst
Resolver IV
Resolver IV

I'm suprised you don't get an error. EOMONTH needs a scalar function as input. You should expect an error message like: A single value for column 'Date' in table 'Date' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

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.