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
Anonymous
Not applicable

removing null values from record type columns

How to remove/ filter out null values of record columns are shown below, 

sanjusanj21_0-1596477544598.png

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Basically you can refer this power query code:

 

let
    
    Source = {
            [Name="A",Age=null],
            [Name="B",Age=20],
            [Name="C",Age=16]

 

        },
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Custom1 = Table.ToRecords(Table.SelectRows( Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Name", "Age"}, {"Column1.Name", "Column1.Age"}),each [Column1.Age]<>null)),
    #"Converted to Table1" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table1"

 

Here is the sample file that hopes to help you: record.pbix

 

Best Regards,
Yingjie Li

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

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Basically you can refer this power query code:

 

let
    
    Source = {
            [Name="A",Age=null],
            [Name="B",Age=20],
            [Name="C",Age=16]

 

        },
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Custom1 = Table.ToRecords(Table.SelectRows( Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Name", "Age"}, {"Column1.Name", "Column1.Age"}),each [Column1.Age]<>null)),
    #"Converted to Table1" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table1"

 

Here is the sample file that hopes to help you: record.pbix

 

Best Regards,
Yingjie Li

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

mahoneypat
Employee
Employee

One option is to expand the record and then filter on the expanded values.  If you want to do it while it is in Record form, you can do it like this.

 

Add a Filter step to any column (to get the basic syntax) and then update it in the Formula bar to get something like this

 

= Table.SelectRows(#"Added Custom", each (Record.Field([RecordColumn], "RecordField") <> null))

 

Where #"Added Custom" is your previous step [RecordColumn] is your column with the Records in it, and "RecordField" is the field within the Record that you are checking if it is null or not.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.