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
Titramed
Regular Visitor

Power Query: Issue with adding lists of numbers to tables

I would expect that the following statement adds a new column with lists of numbers:

Table.AddColumn(#"Table", "Test", each {1, 2, 3})

Instead, the items in the lists are the numbers in text(!) format:

Titramed_0-1692958845623.png

How can I avoid this?

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Though it shows left aligned but type is number only. If you use following, you will find that TRUE is populated in the list

= Table.AddColumn(#"Table", "Test", each List.Transform({1, 2, 3}, (x)=>x is number))

if you use this, you will find FALSE

= Table.AddColumn(#"Table", "Test", each List.Transform({1, 2, 3}, (x)=>x is text))

Now, the type is set for the column not for list which you can do with below statement

= Table.AddColumn(#"Table", "Test", each {1, 2, 3}, type {Int64.Type})

When you expland this column, you will column type is set to Whole number. Otherwise column type will be set to Any.

= Table.AddColumn(#"Table", "Test", each {1, 2, 3}, type {Int64.Type})

View solution in original post

4 REPLIES 4
Vijay_A_Verma
Super User
Super User

Though it shows left aligned but type is number only. If you use following, you will find that TRUE is populated in the list

= Table.AddColumn(#"Table", "Test", each List.Transform({1, 2, 3}, (x)=>x is number))

if you use this, you will find FALSE

= Table.AddColumn(#"Table", "Test", each List.Transform({1, 2, 3}, (x)=>x is text))

Now, the type is set for the column not for list which you can do with below statement

= Table.AddColumn(#"Table", "Test", each {1, 2, 3}, type {Int64.Type})

When you expland this column, you will column type is set to Whole number. Otherwise column type will be set to Any.

= Table.AddColumn(#"Table", "Test", each {1, 2, 3}, type {Int64.Type})

 


@Vijay_A_Verma wrote:

Though it shows left aligned but type is number only.


This is really strange! Do you have an explanation why it's shown left aligned?

 

watkinnc
Super User
Super User

Table.AddColumn(#"Table", "Test", each List.Numbers(1,3,1))

 

--Nate 


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

"{1, 2, 3}" was just an example.
Anyway, your solution gives the same result as described as an issue by me above.

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