conditional on multiple conditions in power bi

44 Views Asked by At

I'm trying to create a conditional that is based on two columns. The first condition is based on a city, let's say it needs to match the value "Texas" and the second condition is a range of values between 111 and 119 (values ending in these values, that I extracted from another column). I tried this but I'm missing something

if [CITY] = "TEXAS" AND [RANGE]>= 111 AND <=119 THEN "VALUE1" ELSE "VALUE2". 

I guess the IN function won't work in this scenario.

Many thanks.

1

There are 1 best solutions below

0
Amira Bedhiafi On

if you're looking to match values that end with 111 to 119, and assuming [RANGE] can be converted or is stored as text, you will need to extract the ending and compare it :

YourMeasure = 
IF(
    AND([CITY] = "TEXAS", 
        OR(
            VALUE(RIGHT(TEXT([RANGE]), 3)) = 111,
            VALUE(RIGHT(TEXT([RANGE]), 3)) >= 112, 
            VALUE(RIGHT(TEXT([RANGE]), 3)) <= 119
        )
    ),
    "VALUE1", 
    "VALUE2"
)