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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
LP280388
Resolver II
Resolver II

Variable in Calculated column not taking a value from nonrelated table

Hi Team,
 
I have the below Measure which results in Yes/No based on the condtions given.  Due to some reason I need to change this measure to a Calculated column so that it can be used in other measure calculations.  but i get a error "cant find name" for the Variables FirstDay and LastDay.   

Please help how to make this as a calculated column.

LP280388_0-1652879332326.png

 



column =
VAR FirstDay = CALCULATE(
MIN('From Date'[Date]),
ALLSELECTED('From Date'[Date]))
VAR LastDay = CALCULATE(
MAX('To Date'[Date]),
ALLSELECTED('To Date'[Date]))
Return
SWITCH(TRUE(),
MAX(VPR[AStartDate]) > LastDay, "No",
MAX(VPR[AStartDate]) >= FirstDay && Max(VPR[AEndDate]) <= LastDay,"Yes",
Max(VPR[AStartDate]) <= FirstDay && Max(VPR[AEndDate]) = BLANK(),"Yes",
MAX(VPR[AStartDate]) <= FirstDay && Max(VPR[AEndDate]) <= FirstDay,"No",
Max(VPR[AEndDate]) <= LastDay,"Yes",
MAX(VPR[AStartDate]) <= FirstDay && Max(VPR[AEndDate]) >= LastDay,"Yes",
Max(VPR[AEndDate]) = BLANK(),"Yes", "")
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @LP280388

 

Try adding a filter() to the formula.

VAR FirstDay =
    CALCULATE (
        MIN ( 'From Date'[Date] ),
        FILTER ( ALLSELECTED ( 'From Date'[Date] )1 = 1 )
    )
VAR LastDay =
    CALCULATE (
        MAX ( 'To Date'[Date] ),
        FILTER ( ALLSELECTED ( 'From Date'[Date] )1 = 1 )
    )

 

Best Regards,

Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @LP280388

 

Try adding a filter() to the formula.

VAR FirstDay =
    CALCULATE (
        MIN ( 'From Date'[Date] ),
        FILTER ( ALLSELECTED ( 'From Date'[Date] )1 = 1 )
    )
VAR LastDay =
    CALCULATE (
        MAX ( 'To Date'[Date] ),
        FILTER ( ALLSELECTED ( 'From Date'[Date] )1 = 1 )
    )

 

Best Regards,

Jay

Thank you very much.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors