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
adoster
Resolver I
Resolver I

DAX SWITCH statement with && to pull values in last 365 days

Hello,

I am trying to build a DAX statement that includes an && statement to only include values within the last 365 days.

 

This statement works (without the 365)

TEST1 = SWITCH (
TRUE(),
'TABLE1'[STATUS] = "OPEN", RELATED ('TABLE2'[OPENVALUE]),
'TABLE1'[STATUS] = "CLOSED", RELATED ('TABLE2'[CLOSEDVALUE]),
BLANK()
)
 
I am trying to add code so that if the STATUS is OPEN && is in the last 365 days THEN OPENVALUE
TEST2 = SWITCH (
TRUE(),
'TABLE1'[STATUS] = "OPEN" && DATEINLAST365DAYS, RELATED ('TABLE2'[OPENVALUE]),
'TABLE1'[STATUS] = "CLOSED", RELATED ('TABLE2'[CLOSEDVALUE]),
BLANK()
)
 
appreciate any assistance.
Thanks!
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @adoster 

try like:

TEST2 = 
SWITCH (
    TRUE(),
    'TABLE1'[STATUS] = "OPEN" 
     && DATEDIFF(TABLE1[Date], TODAY(), DAY)<=365
     RELATED ('TABLE2'[OPENVALUE]),
     'TABLE1'[STATUS] = "CLOSED", 
     RELATED ('TABLE2'[CLOSEDVALUE]),
BLANK()
)
 
add the DATEDIFF part to the closed part if needed.

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @adoster 

try like:

TEST2 = 
SWITCH (
    TRUE(),
    'TABLE1'[STATUS] = "OPEN" 
     && DATEDIFF(TABLE1[Date], TODAY(), DAY)<=365
     RELATED ('TABLE2'[OPENVALUE]),
     'TABLE1'[STATUS] = "CLOSED", 
     RELATED ('TABLE2'[CLOSEDVALUE]),
BLANK()
)
 
add the DATEDIFF part to the closed part if needed.

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric 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.

Users online (25)