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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JumoGra
Frequent Visitor

Using DAX (GENERATESERIES) to show current month's values as at yesterday

Hi There,

I have a calendar table where I'm trying to create a column that shows the current month as at yesterday.  I have managed to create a DAX function, but this unfortunately includes today's date which isn't what I need as shown below in my code.  I'd appreciate if I could get some help with this please.

 

ThisMonth =

var _maxdate = MAX(CDCalendar[CallDate])

return

IF(DATEDIFF('CDCalendar'[CallDate], _maxdate,MONTH) in GENERATESERIES(0,0),1,0)

2 ACCEPTED SOLUTIONS

This worked! Thank you so much for your help with this much appreciated!

View solution in original post

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

View solution in original post

8 REPLIES 8
Ahmedx
Super User
Super User

pls try this code

ThisMonth =
VAR _StartDate = EOMONTH(TODAY(),-1)+1
VAR _EndDate = TODAY()-1

return

IF('CDCalendar'[CallDate]>=_StartDate&&'CDCalendar'[CallDate]<=_EndDate,1,0)

This worked! Thank you so much for your help with this much appreciated!

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

gmsamborn
Super User
Super User

Hi @JumoGra 

 

I added a column to my Date table to display yesterday's month.

 

Yesterday's Month = MONTH( [Date] - 1 )

 

I hope I understood.  Let me know if you have any questions.

 

Display yesterdays MONTH.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

Hi sorry this doesn't work, I'm trying to show all date values in the current month excluding today

Hi @JumoGra 

 

I would like to help but I'm a little unclear about your requirements.

 

Can you provide the following?

 

1)  Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

 

2) Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

 

3) Please explain how you would expect to get from step 1 to 2.

 

4) If possible, please show your past attempts at a solution.

 

 

A .pbix file with sample data would be best.



Proud to be a Super User!

daxformatter.com makes life EASIER!

I've included some of the date columns I'm working with below, basically I need the column 'This Month' to show all values from 1st-15th Mar'24 except today's date i.e. the 16/03/2024 as I have managed to do the same for columns 'Last7Days and yesterday'

JumoGra_0-1710616136095.png

The DAX code below gives me all date values from 1st-16th Mar'24, I want today's date (16/03/24) excluded.

ThisMonth =

var _maxdate = MAX(CDCalendar[CallDate])

return

IF(DATEDIFF('CDCalendar'[CallDate], _maxdate,MONTH) in GENERATESERIES(0,0),1,0)

Have you tried subtracting 1 from the date in your variable in _maxdate?

 

var _maxdate = MAX(CDCalendar[CallDate])- 1



Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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