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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
Shimonkepha
Regular Visitor

How to deal with multiple data types in a column: some rows are tables and others text

Screenshot 2025-01-23 194054.pngThe ones with tables have values, shown on the preview. I can only drill down or add as new query. How do I get the values from the tablesScreenshot 2025-01-23 201105.png

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Shimonkepha I would create 2 new columns that separate out Table values from text values. Then you can work with the Table values without getting errors. Once you have what you need, you can always recombine the 2 columns into a single column once again. PBIX is attached below signature:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxJSU1R0lFycQxx1DU0MlaK1YlWCkrNzS/DFHbOz83NLClBSJiYmoElUAwxt7BUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, KEY = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"KEY", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"KEY"}, {{"Table", each _, type table [NAME=nullable text, KEY=nullable text]}}),
    #"Appended Query" = Table.Combine({#"Grouped Rows", #"Table (2)"}),
    #"Added Custom" = Table.AddColumn(#"Appended Query", "Custom", each if Value.Is(Value.FromText([Table]), type text) then [Table] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if Value.Is(Value.FromText([Table]), type text) then null else [Table]),
    #"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {"NAME"}, {"NAME"}),
    #"Added Custom2" = Table.AddColumn(#"Expanded Custom.1", "Custom.1", each if [Custom] = null then [NAME] else [Custom]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Custom", "NAME"})
in
    #"Removed Columns"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

14 REPLIES 14
v-sgandrathi
Community Support
Community Support

Hi @Shimonkepha ,

Thank you for reaching out Microsoft fabric community forum.

The sample PBIX file provided is inaccessible
Please provide sample data that covers your issue or question completely, in a usable format.

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Regards,
Sahasra.

dufoq3
Super User
Super User

@Shimonkepha, you havent attached source file. We can't use your pbix file without source MS Project to PBI test Data Date 2025-01-17.xml file...


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Hi @Shimonkepha, in Assignments table, add this code as a new step:

 

dufoq3_0-1738065549977.png

= Table.FromColumns(List.TransformMany(Table.ToColumns(#"Expanded TimephasedData"),
        each {Table.Combine(List.Select(_, (x)=> x is table))},
        (x,y)=> List.Combine({List.Select(x, (r)=> not (r is table))} & Table.ToColumns(y)) ), {"Value"} )

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Shimonkepha
Regular Visitor

Hi @Greg_Deckler 

Thanks so much for this but it seems not to work for me. I wish to attach my PBIX file but I cannot, I have sent you a request to connect on LinkedIn. Here is the link to the file on Google Drive

PBI XML File 

jgeddes
Super User
Super User

Another method to try using the try otherwise functionality.
Add this step to your query

 

= Table.TransformColumns(previousQueryStep, {{"columnNameWithTables", each try Table.FirstValue(_) otherwise _}})

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi @jgeddes 

Thanks so much for this but it seems not to work fo me. Here is the link to the file on Google Drive

PBI XML File 

PwerQueryKees
Super User
Super User

That's a challenge...

I would add a step like

Table.TransformColumns("Expanded Time...", {{"Value", each if Value.Is(_, type table) then _ else #table({"TextValue"},{{_}}})  


I am not at my laptop, so Ihave not tested this. If you have trouble fixing errors or making it work, feel free to ask for my help.


Did I answer your question? Then please mark my post as the solution and make it easier to find for others having a similar problem.


If I helped you, please click on the Thumbs Up to give Kudos.

 

Kees Stolker

A big fan of Power Query and Excel

Hi @PwerQueryKees 

Thanks so much for this but it seems not to work fo me. Here is the link to the file on Google Drive

PBI XML File 

You did not include the MS Project export... So I can't see what is happening...

I tried my solution and it works with a small modification:

From

PwerQueryKees_0-1738098774076.png

To 

PwerQueryKees_1-1738098835694.png

With the following code (starting after the 1st screenshot:

...
    Custom1 = Table.TransformColumns(#"Expanded TimephasedData", {{"Value", each if Value.Is(_, type table) then _ else #table({"Element:Text"},{{_}})}}),
    #"Expanded Value" = Table.ExpandTableColumn(Custom1, "Value", {"Element:Text"}, {"Element:Text"})
in
    #"Expanded Value"

Basically what Custom1 does is to tranform the values in the column to a table with one row in one column called Element.Text, if the value iis not a table already...

After that it is the standard expand through the UI.

Did I answer your question? Then please mark my post as the solution and make it easier to find for others having a similar problem.
If I helped you, please click on the Thumbs Up to give Kudos.

Kees Stolker

A big fan of Power Query and Excel

Greg_Deckler
Community Champion
Community Champion

@Shimonkepha I would create 2 new columns that separate out Table values from text values. Then you can work with the Table values without getting errors. Once you have what you need, you can always recombine the 2 columns into a single column once again. PBIX is attached below signature:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxJSU1R0lFycQxx1DU0MlaK1YlWCkrNzS/DFHbOz83NLClBSJiYmoElUAwxt7BUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, KEY = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"KEY", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"KEY"}, {{"Table", each _, type table [NAME=nullable text, KEY=nullable text]}}),
    #"Appended Query" = Table.Combine({#"Grouped Rows", #"Table (2)"}),
    #"Added Custom" = Table.AddColumn(#"Appended Query", "Custom", each if Value.Is(Value.FromText([Table]), type text) then [Table] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if Value.Is(Value.FromText([Table]), type text) then null else [Table]),
    #"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {"NAME"}, {"NAME"}),
    #"Added Custom2" = Table.AddColumn(#"Expanded Custom.1", "Custom.1", each if [Custom] = null then [NAME] else [Custom]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Custom", "NAME"})
in
    #"Removed Columns"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks so much @Greg_Deckler 

I used your method with some modifications on the first custom column that finally worked for me. I believe your process works also! 

Mod: 

if Value.Is([TimephasedData.Value], type text) then [TimephasedData.Value] else 0

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors