cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
gpiero Member
Member

Help to use LIst.Contains()

 

Hi,

 

I am trying to explore how to use List.Contains without results.

I would like to define list of Customer Code List.Contains() instead of write a lot of rows with "or".

The code below does not produce any error, but I do not get the proper result.

 

Could someon help me to understand how to solve this issue?


Regards

 

 

#"Added Conditional Column" = Table.AddColumn(#"Changed Type1", "CS_DLV_EUR1", each if ([Delivery Type] = "ZSDS"
                                                                                           or  [Delivery Type] = "ZSPD")
                                                                                           and [Customer Code] = "32"
                                                                                   then true
                                                                                   /* {248, 129, 936, 215, 253, 245, 1043, 1439, 127, 1032, 217, 218, 224, 212, 32, 1033, 1495, 202, 207, 307, 1031, 252, 306*/        
                                                                                   else if ([Delivery Type] = "ZSDS"
                                                                                           or  [Delivery Type] = "ZSPD")        
                                                                                           and [Customer Code] = "149" 
                                                                                           and [Code Add.Goods] = List.Contains({"Code Add.Goods"}, Text.From({1033, 1495, 32, 300001}))
                                                                                   then true
                                                                                   else false),

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Help to use LIst.Contains()

Hi @gpiero 

It is easy with DAX,

Create a calculated column

Column =
IF (
    [Delivery Type] IN { "ZSDS", "ZSPD" }
        && [Customer Code] = 32,
    TRUE (),
    IF (
        [Delivery Type] IN { "ZSDS", "ZSPD" }
            && [Customer Code] = 149
            && [Code Add.Goods] IN { 1033, 1495, 32, 300001 },
        TRUE ()
    )
)

3.png

Assume [Customer Code] and [Code Add.Goods] are of number type not text,

If they are text, replace [Customer Code] = 32 with [Customer Code] = "32",

[Code Add.Goods] IN { 1033, 1495, 32, 300001 } with [Code Add.Goods] IN { "1033", "1495", "32", "300001" }.

 

Best Regards
Maggie

 

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

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Help to use LIst.Contains()

Hi @gpiero 

It is easy with DAX,

Create a calculated column

Column =
IF (
    [Delivery Type] IN { "ZSDS", "ZSPD" }
        && [Customer Code] = 32,
    TRUE (),
    IF (
        [Delivery Type] IN { "ZSDS", "ZSPD" }
            && [Customer Code] = 149
            && [Code Add.Goods] IN { 1033, 1495, 32, 300001 },
        TRUE ()
    )
)

3.png

Assume [Customer Code] and [Code Add.Goods] are of number type not text,

If they are text, replace [Customer Code] = 32 with [Customer Code] = "32",

[Code Add.Goods] IN { 1033, 1495, 32, 300001 } with [Code Add.Goods] IN { "1033", "1495", "32", "300001" }.

 

Best Regards
Maggie

 

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

View solution in original post

gpiero Member
Member

Re: Help to use LIst.Contains()

@v-juanli-msft 

Many thanks for solution.

Yes, it is clear, in DAX we can do in this way.

 

I only wanted to understand how to replicate the same in Power Query.

 

Thanks again

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors