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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dicken
Continued Contributor
Continued Contributor

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
Super User
Super User

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
Continued Contributor
Continued Contributor

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
Super User
Super User

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
Continued Contributor
Continued Contributor

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.