cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LP280388
Helper II
Helper 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
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Thank you very much.

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show Episode 10 Recap

The Power BI Community Show

Watch the playback when Amit Chandak, a Power BI Super User, demos how to use Field Parameters to make reports more dynamic.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.

Top Solution Authors