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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

If current month, apply one formula, if not, use another

Hi everyone,

I am basically trying to get working days to date, but if it's current month, i need it to show working days till yesterday (exclude today). 

I am trying to use the below formula, but the bolded part gives me an error saying a single value cannot be determined (The Data File is basically when employees submit something everyday, so there are multiple of each dates):

 

Working days to date =

IF(
MONTH('DataFile'[Date]) = MONTH(TODAY()),
CALCULATE(
SUM('Date Table'[Work day]),
KEEPFILTERS('Date Table'[Date]<= TODAY())
) -1,
CALCULATE(
SUM('Date Table'[Work day]),
KEEPFILTERS('Date Table'[Date]<= TODAY())
)
)
 
Is this doable? This measure will need to be integrated into another measure to get compliance, so it needs to be a measure not a column. 
Thank you in advance! 
1 ACCEPTED SOLUTION
Watsky
Solution Sage
Solution Sage

Hey @Anonymous ,

 

How about this?

 

 

 

Working days to date = 
VAR a = CALCULATE(SUM('Date Table'[Workday]),MONTH('DataFile'[Date])=MONTH(TODAY()),KEEPFILTERS('Date Table'[Date]<=TODAY()))
VAR b = SELECTEDVALUE('DataFile'[Date])
RETURN
IF(MONTH(b)=MONTH(TODAY()),a-1,a)

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi  @Anonymous ,

You can modify the formula as follows and add a max:

IF(
MONTH(MAX('DataFile'[Date])) = MONTH(TODAY()),
CALCULATE(
SUM('Date Table'[Work day]),
KEEPFILTERS('Date Table'[Date]<= TODAY())
) -1,
CALCULATE(
SUM('Date Table'[Work day]),
KEEPFILTERS('Date Table'[Date]<= TODAY())
)
)

 

Best Regards,

Liu Yang

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

Watsky
Solution Sage
Solution Sage

Hey @Anonymous ,

 

How about this?

 

 

 

Working days to date = 
VAR a = CALCULATE(SUM('Date Table'[Workday]),MONTH('DataFile'[Date])=MONTH(TODAY()),KEEPFILTERS('Date Table'[Date]<=TODAY()))
VAR b = SELECTEDVALUE('DataFile'[Date])
RETURN
IF(MONTH(b)=MONTH(TODAY()),a-1,a)

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Anonymous
Not applicable

This worked, thank you!!! 

Anonymous
Not applicable

This works for current month, but when i filter to previous month, it wont work 😞 i have a card to show this formula, and it remains the same regardless of whta I select in the month slicer. 

Can you give an example of what the result should look like?


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

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.

Top Solution Authors