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
CarlBlunck
Resolver I
Resolver I

Expression.Error: We cannot convert the value "" to type List.

Hi community,

I'm real new to powerBI and am getting this error in the following nested if statement:

Nested if statement:

 

= Table.AddColumn(#"Added Custom1", "Custom", each if [HRStreamDesc] <> "Nursing" then null else 
if List.ContainsAny([BaseClass],{"AN","ANCSD"}) then "Assistant in Nursing" else null)

 

Error message I am receiving:

 

Expression.Error: We cannot convert the value "QNG6" to type List.
Details:
    Value=QNG6
    Type=[Type]

 

Any assistance on how to overcome this would be appreciated.

Basically I need to create a new column based on the value that exists in another column, should be a simple nested if statement...

Cheers

Carl

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @CarlBlunck ,

 

Please try:

if [HRStreamDesc]<>"Nursing" then null else if List.ContainsAny( {[BaseClass]},{"AN","ANCSD"}) then "Assistant in Nursing" else null

Eyelyn9_1-1658383335591.png

 

Best Regards,
Eyelyn Qin
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

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @CarlBlunck ,

 

I used { } To convert the Value to List type.

 

Best Regards,
Eyelyn Qin

v-eqin-msft
Community Support
Community Support

Hi @CarlBlunck ,

 

Please try:

if [HRStreamDesc]<>"Nursing" then null else if List.ContainsAny( {[BaseClass]},{"AN","ANCSD"}) then "Assistant in Nursing" else null

Eyelyn9_1-1658383335591.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-eqin-msft thanks so much!  To help me understand, what does the addition of the {} brackets do to the [BaseClass] column?

Cheers

Carl

mussaenda
Super User
Super User

Hi @CarlBlunck ,

 

Please try this

 Table.AddColumn(#"Added Custom1", "Custom", each try if [HRStreamDesc] <> "Nursing" then null else 
if List.ContainsAny([BaseClass],{"AN","ANCSD"}) then "Assistant in Nursing" else null otherwise null)

Hi @mussaenda thanks - but I unfortunately get a "Token Eof expected" error and the otherwise statement is being highlighted.

CarlBlunck_0-1658122562957.png

 

@mussaenda ah I missed the inclusion of the each try if element.  That got rid of the error but now everything is just coming back as a null...

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.

Top Solution Authors
Top Kudoed Authors