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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Dicken
Responsive Resident
Responsive Resident

Some help on understanding nullable types

Can someone help in my undertanding of nullable, for example if I create a table ; 

= #table ( type table [A =  text  , B =nullable  text  ], 
 { {"aa", "x"}, { "x", "aa" }} ) 

 and then add a could of columns ; 

= Table.AddColumn( 
Table.AddColumn(Source, "M", each
Type.IsNullable(  Value.Type( [A]))), 
"N", each Type.IsNullable( Value.Type( [B])))

 Both result in false,   but if I use Tabel.Schemal  'is nullable' = true for A and false for B which is what I would have expected, 
Can somone explain or point me in the direction of some detailed information on these functions. 

 

Richard 

2 ACCEPTED SOLUTIONS
MarkLaf
Memorable Member
Memorable Member

In your table definition, you are saying the column / row field is nullable - i.e. we are saying for a structured data value, it can contain multiple types of primitive values (text or null).

 

In your AddColumn test, you're basically doing:

1: Type.IsNullable( Value.Type( "x" ) )

2: Type.IsNullable( Value.Type( "aa" ) )

So, it makes sense when you are looking at a primitive text value that PQ would say that it is not nullable.

 

So, where does the nullability apply? We know [B] is nullable because we just defined the table, but how would we find out otherwise?

 

Table.Schema shows you the column types and whether they are nullable, as you already pointed out. Although, it provides a sort of analytical output (primitive type, isNullable, NumericPrecision, etc.) rather than a straight here is the type.

TableTest = Table.Schema( Source )

MarkLaf_0-1720648477012.png

 

So, is it possible to do some test/expression on [B] that results in nullable text? Yes! As I mentioned at the top, it's all about looking at the type from a structured data perspective as that actually is the only context in which the "nullable" modifier makes sense. Again, besides null, which is its own type, no primitive value is nullable by definition.


ColTypeTest = Type.TableColumn( Value.Type( Source ), "B" )

MarkLaf_1-1720648738210.png


RowTypeTest = Type.RecordFields( Type.TableRow( Value.Type( Source ) ) ) [B] [Type]

MarkLaf_3-1720648767141.png

 

ColListTest = Type.ListItem( Value.Type( Source[B] ) )

MarkLaf_2-1720648758567.png

 

RowRecordTest = Type.RecordFields( Type.ListItem( Value.Type( Table.ToRecords( Source ) ) ) ) [B] [Type]

MarkLaf_2-1720648758567.png

View solution in original post

Dicken
Responsive Resident
Responsive Resident

Thank you 

I'm going to have to go through this a few times, (or more)  my musunderstanding I think is that if I define a column as a nullable type then all values in that column should be nullable but this does not seem to be the case. One thing I have notices, the change type step  does not say nullable but if  group 

= Table.Group(#"Changed Type", {"Column1"}, {{"Count", each _, type table [Column1=nullable text]}})

 Table.Group(Source , {"Column1"}, {{"Count", each _, type table [Column1=text]}})

 types are defined as nullable or not, not sure what use it is just thought interestign. 

 

Richard. 

= Table.Group(#"Changed Type", {"Column1"}, {{"Count", each _, type table [Column1=nullable text]}})

 

View solution in original post

2 REPLIES 2
MarkLaf
Memorable Member
Memorable Member

In your table definition, you are saying the column / row field is nullable - i.e. we are saying for a structured data value, it can contain multiple types of primitive values (text or null).

 

In your AddColumn test, you're basically doing:

1: Type.IsNullable( Value.Type( "x" ) )

2: Type.IsNullable( Value.Type( "aa" ) )

So, it makes sense when you are looking at a primitive text value that PQ would say that it is not nullable.

 

So, where does the nullability apply? We know [B] is nullable because we just defined the table, but how would we find out otherwise?

 

Table.Schema shows you the column types and whether they are nullable, as you already pointed out. Although, it provides a sort of analytical output (primitive type, isNullable, NumericPrecision, etc.) rather than a straight here is the type.

TableTest = Table.Schema( Source )

MarkLaf_0-1720648477012.png

 

So, is it possible to do some test/expression on [B] that results in nullable text? Yes! As I mentioned at the top, it's all about looking at the type from a structured data perspective as that actually is the only context in which the "nullable" modifier makes sense. Again, besides null, which is its own type, no primitive value is nullable by definition.


ColTypeTest = Type.TableColumn( Value.Type( Source ), "B" )

MarkLaf_1-1720648738210.png


RowTypeTest = Type.RecordFields( Type.TableRow( Value.Type( Source ) ) ) [B] [Type]

MarkLaf_3-1720648767141.png

 

ColListTest = Type.ListItem( Value.Type( Source[B] ) )

MarkLaf_2-1720648758567.png

 

RowRecordTest = Type.RecordFields( Type.ListItem( Value.Type( Table.ToRecords( Source ) ) ) ) [B] [Type]

MarkLaf_2-1720648758567.png

Dicken
Responsive Resident
Responsive Resident

Thank you 

I'm going to have to go through this a few times, (or more)  my musunderstanding I think is that if I define a column as a nullable type then all values in that column should be nullable but this does not seem to be the case. One thing I have notices, the change type step  does not say nullable but if  group 

= Table.Group(#"Changed Type", {"Column1"}, {{"Count", each _, type table [Column1=nullable text]}})

 Table.Group(Source , {"Column1"}, {{"Count", each _, type table [Column1=text]}})

 types are defined as nullable or not, not sure what use it is just thought interestign. 

 

Richard. 

= Table.Group(#"Changed Type", {"Column1"}, {{"Count", each _, type table [Column1=nullable text]}})

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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