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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
KW123
Helper V
Helper V

IF with a Filter?

Hi, 

I have the following DAX to calculate a value for the last day of the previous month. 

YTDFunded =
CALCULATE(
SUMX(
'2022 Goals',
'2022 Goals'[WWARYTD]
),
FILTER(
ALL(Dates),
(Dates[Date] = MAXX(Dates, Dates[Last day of previous monthC]
))))

However I am trying to put and IF clause that makes the values for just January blank.  
IF MONTH ( SELECTEDVALUE ( Dates[Date] ) ) = 1,
Blank(),

I just don't know where in the above DAX to put it as it keeps returning an error. 

Thanks


1 ACCEPTED SOLUTION
ValtteriN
Community Champion
Community Champion

Hi, 

For your syntax, it seems there is a ) in the wrong position:

IF(SELECTEDVALUE ('Dates'[Date]))

Move the bolded ")" to the very end of your dax.

As for alternative dax try something with this kind of idea:

Measure 21 =

var _lmend = ENDOFMONTH(DATEADD('Calendar'[Date],-1,MONTH)) return

CALCULATE(sum(Table1[Value]), ALL('Calendar'[Date]),'Calendar'[Date]=_lmend)







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
KW123
Helper V
Helper V

@ValtteriN That worked!! Thank you very much for your help 

ValtteriN
Community Champion
Community Champion

Hi,

Place the IF in the beginning of your DAX e.g. IF(SELECTEDVALUE ( Dates[Date] ) ) = 1, BLANK(), [YTDFunded]

As a sidenote for last day of a month try using ENDOFMONTH function.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ValtteriN Thank you for your help! 
What I am I doing incorrectly? With this DAX it is returning an error of 'incorrect syntax'

YTDFunded =
IF(SELECTEDVALUE ('Dates'[Date])) = 1, BLANK(),

CALCULATE(
SUMX(
'2022 Goals',
'2022 Goals'[WWARYTD]
),
 
FILTER(
 
ALL(Dates),
(Dates[Date] = MAXX(Dates, Dates[Last day of previous monthC]
))))

@ValtteriN Also thank you for your suggestion with ENDOFMONTH. 
Is there a different DAX I should be using to get what I need instead with the ENDOFMONTH and the IF?

ValtteriN
Community Champion
Community Champion

Hi, 

For your syntax, it seems there is a ) in the wrong position:

IF(SELECTEDVALUE ('Dates'[Date]))

Move the bolded ")" to the very end of your dax.

As for alternative dax try something with this kind of idea:

Measure 21 =

var _lmend = ENDOFMONTH(DATEADD('Calendar'[Date],-1,MONTH)) return

CALCULATE(sum(Table1[Value]), ALL('Calendar'[Date]),'Calendar'[Date]=_lmend)







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.