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! Learn more

Reply
GeorgiGeorgiev4
Regular Visitor

Only one particular part of IF statement always returns FALSE value

I have the following formula:

 

CurrentYear = var _a = YEAR(TODAY())
return IF(WEEKNUM(TODAY(),21)>10 && YEAR(TODAY())=_a-1, IF(MAX('RegionsTableFull'[LoadingYearC])=_a-1, 1, 0),
IF(WEEKNUM(TODAY(),21)>=4 && WEEKNUM(TODAY(),21)<10,
IF(MAX('RegionsTableFull'[LoadingYearC])=_a, 1, 0),
IF(WEEKNUM(TODAY(),21)<=3, IF(MAX('RegionsTableFull'[LoadingYearC])=_a, 1, 3))))

 

Everything was working fine yesterday going into the WEEKNUM(TODAY())>10. But now, when it is 02.01.2023 and my IF goes to the last part <=3 I always get the FALSE result of 3 instead of 1. I have absolutely no idea where the issue might be here, because apparently I satisfy the condition for week number, but I never satisfy the condition for MAX LoadingYearC=_a.

GeorgiGeorgiev4_0-1672643054921.png

As you can see in the image I have data that has 2023 in LoadingYearC and YEAR(TODAY()) is in fact 2023.

 

What is the problem here?

2 REPLIES 2
amitchandak
Super User
Super User

@GeorgiGeorgiev4 , Try this

 

Switch( True() ,
WEEKNUM(TODAY(),21)<=3 && MAX('RegionsTableFull'[LoadingYearC])=_a, 1,
WEEKNUM(TODAY(),21)<=3 ,3 ,
WEEKNUM(TODAY(),21)<10 && MAX('RegionsTableFull'[LoadingYearC])=_a , 1 ,
WEEKNUM(TODAY(),21)<10 , 0,
YEAR(TODAY())=_a-1 && MAX('RegionsTableFull'[LoadingYearC])=_a-1 , 1 ,
0)

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

Hello @amitchandak ,

 

Thank you for the quick reply!

 

Literally 3 minutes ago my code magically started working for some god-unknown reason without me doing anything. If it breaks again I will try your code, because I am afraid if I touch it again what might happen.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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