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
LD1
Helper III
Helper III

Fonction IF et NOT CONTAINS

Bonjour à tous, 

 

Je cherche à reproduire cette formule en formule dax svp:

 

IF [Maison]='Maison 1' THEN

      IF NOT  [Pièce maison] in ('Cuisine',"SDB",null) THEN 1

ELSE 0 END

ELSEIF [Maison]="Maison 2" THEN

      IF NOT [Pièce maison] in ("Salon","Chambre",null) THEN 1

ELSE 0 END

END

 

Je n'ai rien trouvé sur internet..

Merci d'avance pour votre aide et bonne journée, 

LD

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

With this sample table

table.jpg

You can flag the items using a measure as follows:

Not in list =
VAR _Values =
    VALUES ( 'Table'[Item] )
VAR _M1 = { "Bed", "Chair", "Door" }
VAR _M2 = { "Blanket", "Curtain", "Sheet" }
RETURN
    SWITCH (
        TRUE (),
        AND (
            SELECTEDVALUE ( 'Table'[House] ) = "Maison 1",
            SELECTEDVALUE ( 'Table'[Item] )
                IN EXCEPT ( _Values, _M1 ) //checks if item is in table excluding the values listed in _M1
        ), 1,
        AND (
            SELECTEDVALUE ( 'Table'[House] ) = "Maison 2",
            SELECTEDVALUE ( 'Table'[Item] )
                IN EXCEPT ( _Values, _M2 ) //checks if item is in table excluding the values listed in _M2
        ), 1,
        0
    )

result.jpg

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

1 REPLY 1
PaulDBrown
Community Champion
Community Champion

With this sample table

table.jpg

You can flag the items using a measure as follows:

Not in list =
VAR _Values =
    VALUES ( 'Table'[Item] )
VAR _M1 = { "Bed", "Chair", "Door" }
VAR _M2 = { "Blanket", "Curtain", "Sheet" }
RETURN
    SWITCH (
        TRUE (),
        AND (
            SELECTEDVALUE ( 'Table'[House] ) = "Maison 1",
            SELECTEDVALUE ( 'Table'[Item] )
                IN EXCEPT ( _Values, _M1 ) //checks if item is in table excluding the values listed in _M1
        ), 1,
        AND (
            SELECTEDVALUE ( 'Table'[House] ) = "Maison 2",
            SELECTEDVALUE ( 'Table'[Item] )
                IN EXCEPT ( _Values, _M2 ) //checks if item is in table excluding the values listed in _M2
        ), 1,
        0
    )

result.jpg

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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.