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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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