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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
andytmcc
Helper I
Helper I

If this == this or this

I have a filter that includes the line 'Loneliness All Data'[VARIABLE] == "Parliamentary Constituency". I also want this filter to include "LGD" i.e, if the variable column is equal to Parliamentary Constituency or LGD. How do I add in the LGD? I'm sure this must be easy but I'm a newbie and can't figure it out at all! 

 

 Here is my code: 

 
LOC Previous Year =
VAR PreviousRow =
TOPN (
1,
FILTER (
'Loneliness All Data',
'Loneliness All Data'[YEAR] < EARLIER ( 'Loneliness All Data'[YEAR] )
&& 'Loneliness All Data'[CATEGORY] = EARLIER ( 'Loneliness All Data'[CATEGORY] ) && 'Loneliness All Data'[VARIABLE] == "Parliamentary Constituency"
),
[YEAR], DESC
)
VAR PreviousValue =
MINX ( PreviousRow, [Locus Of Control Mean] )
RETURN
PreviousValue
1 ACCEPTED SOLUTION
ReneMoawad
Resolver III
Resolver III

Hi @andytmcc,

 

You can use it like this && 'Loneliness All Data'[VARIABLE] IN {"Parliamentary Constituency", "LGD"}

View solution in original post

8 REPLIES 8
andytmcc
Helper I
Helper I

@ReneMoawad  How would I put this same filter requirement FILTER('Loneliness All Data'[VARIABLE] IN {"Parliamentary Constituency", "LGD"} into this code:

 

LOC_conditionalFormat =
SWITCH (
TRUE (),
OR (
ISBLANK ( 'Loneliness All Data'[Locus Of Control Mean] ),
ISBLANK ( 'Loneliness All Data'[LOC Previous Year] )
), 4,
'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[LOC Previous Year], 1,
'Loneliness All Data'[Locus Of Control Mean] < 'Loneliness All Data'[LOC Previous Year], 2,
'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[LOC Previous Year], 3
)

 

Thanks!

LOC_conditionalFormat =
SWITCH (TRUE()
    , ISBLANK ('Loneliness All Data'[Locus Of Control Mean]) || ISBLANK('Loneliness All Data'[LOC Previous Year]), 4
    , 'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[LOC Previous Year], 1
    , 'Loneliness All Data'[Locus Of Control Mean] < 'Loneliness All Data'[LOC Previous Year], 2
    , 'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[LOC Previous Year], 3
)

Sorry, i didn't mean how would I use the || in that. I meant how would I put this filter FILTER('Loneliness All Data'[VARIABLE] IN {"Parliamentary Constituency", "LGD"} into this code below:

 

LOC_conditionalFormat =
SWITCH (
TRUE (),
OR (
ISBLANK ( 'Loneliness All Data'[Locus Of Control Mean] ),
ISBLANK ( 'Loneliness All Data'[LOC Previous Year] )
), 4,
'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[LOC Previous Year]1,
'Loneliness All Data'[Locus Of Control Mean] < 'Loneliness All Data'[LOC Previous Year]2,
'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[LOC Previous Year]3
)

 

LOC_conditionalFormat =
Var output = SWITCH (
TRUE (),
OR (
ISBLANK ( 'Loneliness All Data'[Locus Of Control Mean] ),
ISBLANK ( 'Loneliness All Data'[LOC Previous Year] )
), 4,
'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[LOC Previous Year]1,
'Loneliness All Data'[Locus Of Control Mean] < 'Loneliness All Data'[LOC Previous Year]2,
'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[LOC Previous Year]3
)
RETURN
IF(All Data'[VARIABLE] IN {"Parliamentary Constituency", "LGD"}, output, BLANK())

Thank you so much!

andytmcc
Helper I
Helper I

Hi @ReneMoawad , 

That's fantastic - thank you so much! I had been trying to use OR but couldn't figure it out. First time coming across IN for me!

Also instead of OR you can use double vertical bar ||

ReneMoawad
Resolver III
Resolver III

Hi @andytmcc,

 

You can use it like this && 'Loneliness All Data'[VARIABLE] IN {"Parliamentary Constituency", "LGD"}

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.