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

Previous dates using date add and switch

Hi,

 

Thanks in advance for the support. The objective is to make a measure that gives the previous aummount for any date, excluding holidays and weekends. I was using the "is holiday" and "is weekend" from the model calendar table to switch between diferents dateadd for some aggregation measure, but it gave error as result.

 

measure := calculate(aggregateMeasure,

switch(TRUE(),

calendar[isHoliday] = 1 and calendar[day] = 5, dateadd(calendar[date], - 4, day),

... //for every use case

but the result is error : /

 

thanks for any help

2 REPLIES 2
Anonymous
Not applicable

Of course you get an error because SWITCH cannot return a table and tables and tables only can be filters in CALCULATE. Also, calling field names without wrapping them into an aggregation function when there's no row context must lead to errors.

Please try to read something about CALCULATE and how filters work in DAX.

By the way, your case is not clear at all. Please explain in detail what you want to do and then someone will certainly be able to help you.

Best
D
amitchandak
Super User
Super User

@Lenastray , Not very clear. Check if this can help

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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