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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Dicken
Post Prodigy
Post Prodigy

Lists of text and number types

Hi, 
can someoen explain this ; if you have a llsit 

 = let alist = 
 {1,"a","b",3,3} in alist


you get a list of text and number alignment's left and right , but if you have a nested list 

= let alist = 
{ {"a",1} , {"b",2} , {"c", 3}} 
in alist


then all is left or text aligned,   any ideas as to what happens between one and nested to cause this? 

Richard

3 ACCEPTED SOLUTIONS
AmiraBedh
Super User
Super User

Hello Dicken !

What you’re seeing is just the PQ UI is reacting to types.

{1,"a","b",3,3} each element is a scalar value and PQ knows the type of each item and the preview grid aligns them accordingly: numbers right, text left.

 

{{"a",1},{"b",2},{"c",3}} here each element of the outer list is itself a list and in the preview, PQ doesn’t look inside those inner lists when they decide alignment so it just shows values which are aligned like text. If you expand them, the columns start as type any which also aligns left until you set a numeric type.

 

So if you want the proper numeric right alignment, turn that nested list into a real table and set types:

let
    alist   = { {"a",1}, {"b",2}, {"c",3} },
    asTable = Table.FromRows(alist, {"Letter","Number"}),
    typed   = Table.TransformColumnTypes(asTable, {{"Letter", type text}, {"Number", Int64.Type}})
in
    typed

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

vojtechsima
Super User
Super User

Hey, @Dicken ,

Lists are lazily evaluated. On demand, Power Query evaluates the top-level and structure. If you would nest the same list as in your first example:

let alist = {
 {1,"a","b",3,3}} in alist

You'll get the same behaviour, everything as text:

vojtechsima_0-1762097304082.png

Once you go inside and inspect each value separately, you'll see the types evaluated precisely:

vojtechsima_1-1762097336024.png

 

I general, Power Query wants to be as lazy as possible, if it doesn'T have to evaluate something, it won'T, so unless you call the concrete item in a list (for example by displaying the lowest nested items), it won't do the types as you would expect.

 

More on evaluation in my blog:

https://www.vojtechsima.com/post/how-power-query-m-evaluates-your-queries-and-why-the-performance-ge...






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

View solution in original post

@Dicken 
Yeah, basically. Until you evaluate a specific item from the nested list, you MAY not get the type. The may is important, as it's kinda specific to lists, as you can see it does differentiate between the types, and for exampl,e tables preview will show you the correct representation immediately.

See example:

= {
#table({"col1", "col2", "col3"}, {{"a", "b", 1}}), {1,2,3, "1", "a"}
}

 

vojtechsima_0-1762099569881.pngvojtechsima_1-1762099573412.png

 






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

View solution in original post

5 REPLIES 5
vojtechsima
Super User
Super User

Hey, @Dicken ,

Lists are lazily evaluated. On demand, Power Query evaluates the top-level and structure. If you would nest the same list as in your first example:

let alist = {
 {1,"a","b",3,3}} in alist

You'll get the same behaviour, everything as text:

vojtechsima_0-1762097304082.png

Once you go inside and inspect each value separately, you'll see the types evaluated precisely:

vojtechsima_1-1762097336024.png

 

I general, Power Query wants to be as lazy as possible, if it doesn'T have to evaluate something, it won'T, so unless you call the concrete item in a list (for example by displaying the lowest nested items), it won't do the types as you would expect.

 

More on evaluation in my blog:

https://www.vojtechsima.com/post/how-power-query-m-evaluates-your-queries-and-why-the-performance-ge...






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

Thanks to both, I have a look at the blog, so let me see if i get this,   as 
lists are nested,     {  {} }   the first level is a list not a number which affects subsequent values ? 

@Dicken 
Yeah, basically. Until you evaluate a specific item from the nested list, you MAY not get the type. The may is important, as it's kinda specific to lists, as you can see it does differentiate between the types, and for exampl,e tables preview will show you the correct representation immediately.

See example:

= {
#table({"col1", "col2", "col3"}, {{"a", "b", 1}}), {1,2,3, "1", "a"}
}

 

vojtechsima_0-1762099569881.pngvojtechsima_1-1762099573412.png

 






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

thanks for the help.

AmiraBedh
Super User
Super User

Hello Dicken !

What you’re seeing is just the PQ UI is reacting to types.

{1,"a","b",3,3} each element is a scalar value and PQ knows the type of each item and the preview grid aligns them accordingly: numbers right, text left.

 

{{"a",1},{"b",2},{"c",3}} here each element of the outer list is itself a list and in the preview, PQ doesn’t look inside those inner lists when they decide alignment so it just shows values which are aligned like text. If you expand them, the columns start as type any which also aligns left until you set a numeric type.

 

So if you want the proper numeric right alignment, turn that nested list into a real table and set types:

let
    alist   = { {"a",1}, {"b",2}, {"c",3} },
    asTable = Table.FromRows(alist, {"Letter","Number"}),
    typed   = Table.TransformColumnTypes(asTable, {{"Letter", type text}, {"Number", Int64.Type}})
in
    typed

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.