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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Expand array to columns

Hi,

 

I have the following array loaded in Power BI

[{"hours":[{"startTime":"13:00:00","endTime":"17:00:00","weekdays":["MON"]},{"startTime":"10:00:00","endTime":"17:00:00","weekdays":["TUE"]},{"startTime":"10:00:00","endTime":"17:00:00","weekdays":["WED"]},{"startTime":"10:00:00","endTime":"17:00:00","weekdays":["THU"]},{"startTime":"10:00:00","endTime":"21:00:00","weekdays":["FRI"]},{"startTime":"10:00:00","endTime":"17:00:00","weekdays":["SAT"]},{"startTime":"12:00:00","endTime":"17:00:00","weekdays":["SUN"]}]}]z

 

Power BI recognize this as a string inside the whole table therefor I cannot expand this.

What is the best possible way to expand this array to multiple columns inside the table? 

1 ACCEPTED SOLUTION
westwrightj
Resolver III
Resolver III

Hey @Anonymous ,

 

   Similar to what @Pragati11  had mentioned - it is difficult to really assess your solution without some more details on how this data is structued and being loaded.

 

   That being said, is this is just coming through as a single cell/array and the data you provided is static this might be a workable solution for you

 

So right now we are starting with this data

 

westwrightj_0-1594904200790.png

 

We can split the data at each day using this delimite in Power Query

 

westwrightj_1-1594904339615.png

 

Add each column as a unique query using "Add as New Query"

 

Here is if we use column 2 as an example

 

westwrightj_2-1594904398106.png

 

 

Convert to a table with comma as the delimiter

 

westwrightj_3-1594904427501.png

 

We can then do a few custom columns

 

Start Time

Text.AfterDelimiter([Column1], ":")

End Time

Text.AfterDelimiter([Column2], ":")

Weekday

Text.AfterDelimiter([Column2], ":")

 

Then we can remove the old columns

 

And remove the brackets from the Weekday column. You will now have this data left

 

westwrightj_5-1594904897705.png

 

You can then take all of the steps from the advanced editor and copy and paste the other columns from your original table savings you some work

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUcrILy0qjlGyArGLSxKLSkIyc1OB/BglQ2MrAwMgilHSiVFKzUtBSJgjSZSnpmanJFaCjYhR8vX3i1GKrdXBNMyAdMNCQl2pZ1i4qwsVXeYRSqJhRoY4DXML8qSey4IdQ3AYZkSGYaHg2ATCKqXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test_Data = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Test_Data", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Test_Data", Splitter.SplitTextByDelimiter("},", QuoteStyle.Csv), {"Test_Data.1", "Test_Data.2", "Test_Data.3", "Test_Data.4", "Test_Data.5", "Test_Data.6", "Test_Data.7"}),
    #"Test_Data 3" = #"Split Column by Delimiter"[Test_Data.2],
    #"Converted to Table" = Table.FromList(#"Test_Data 3", Splitter.SplitTextByDelimiter(","), null, null, ExtraValues.Error),
    #"Changed Type1" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "StartTime", each Text.AfterDelimiter([Column1], ":")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "EndTime", each Text.AfterDelimiter([Column2], ":")),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Weekday", each Text.AfterDelimiter([Column3], ":")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Column1", "Column2", "Column3"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns","[","",Replacer.ReplaceText,{"Weekday"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","]","",Replacer.ReplaceText,{"Weekday"})
in
    #"Replaced Value1"

 

Once you've done that with each weekday, go ahead and append your data and it will look like this (I only did Tues and Wednesday)

 

westwrightj_6-1594905015581.png

 

 

I realize this is a clunky solution but, let us know if it works. If not we can keep noodling away at it!

 

 

 

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi all,

 

Sorry for my late response. 

Thank you very much for all your help guys. Both solutions are working fine for me! 🙂

camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this custom column:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUcrILy0qjlGyArGLSxKLSkIyc1OB/BglQ2MrAwMgilHSiVFKzUtBSJgjSZSnpmanJFaCjYhR8vX3i1GKrdXBNMyAdMNCQl2pZ1i4qwsVXeYRSqJhRoY4DXML8qSey4IdQ3AYZkSGYaHg2ATCKqXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.FromRecords(Json.Document(Text.RemoveRange([Column1], Text.Length([Column1]) - 1)){0}[hours])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"startTime", "endTime", "weekdays"}, {"startTime", "endTime", "weekdays"}),
    #"Expanded weekdays" = Table.ExpandListColumn(#"Expanded Custom", "weekdays")
in
    #"Expanded weekdays"

 

 



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

Proud to be a Super User!



westwrightj
Resolver III
Resolver III

Hey @Anonymous ,

 

   Similar to what @Pragati11  had mentioned - it is difficult to really assess your solution without some more details on how this data is structued and being loaded.

 

   That being said, is this is just coming through as a single cell/array and the data you provided is static this might be a workable solution for you

 

So right now we are starting with this data

 

westwrightj_0-1594904200790.png

 

We can split the data at each day using this delimite in Power Query

 

westwrightj_1-1594904339615.png

 

Add each column as a unique query using "Add as New Query"

 

Here is if we use column 2 as an example

 

westwrightj_2-1594904398106.png

 

 

Convert to a table with comma as the delimiter

 

westwrightj_3-1594904427501.png

 

We can then do a few custom columns

 

Start Time

Text.AfterDelimiter([Column1], ":")

End Time

Text.AfterDelimiter([Column2], ":")

Weekday

Text.AfterDelimiter([Column2], ":")

 

Then we can remove the old columns

 

And remove the brackets from the Weekday column. You will now have this data left

 

westwrightj_5-1594904897705.png

 

You can then take all of the steps from the advanced editor and copy and paste the other columns from your original table savings you some work

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUcrILy0qjlGyArGLSxKLSkIyc1OB/BglQ2MrAwMgilHSiVFKzUtBSJgjSZSnpmanJFaCjYhR8vX3i1GKrdXBNMyAdMNCQl2pZ1i4qwsVXeYRSqJhRoY4DXML8qSey4IdQ3AYZkSGYaHg2ATCKqXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test_Data = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Test_Data", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Test_Data", Splitter.SplitTextByDelimiter("},", QuoteStyle.Csv), {"Test_Data.1", "Test_Data.2", "Test_Data.3", "Test_Data.4", "Test_Data.5", "Test_Data.6", "Test_Data.7"}),
    #"Test_Data 3" = #"Split Column by Delimiter"[Test_Data.2],
    #"Converted to Table" = Table.FromList(#"Test_Data 3", Splitter.SplitTextByDelimiter(","), null, null, ExtraValues.Error),
    #"Changed Type1" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "StartTime", each Text.AfterDelimiter([Column1], ":")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "EndTime", each Text.AfterDelimiter([Column2], ":")),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Weekday", each Text.AfterDelimiter([Column3], ":")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Column1", "Column2", "Column3"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns","[","",Replacer.ReplaceText,{"Weekday"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","]","",Replacer.ReplaceText,{"Weekday"})
in
    #"Replaced Value1"

 

Once you've done that with each weekday, go ahead and append your data and it will look like this (I only did Tues and Wednesday)

 

westwrightj_6-1594905015581.png

 

 

I realize this is a clunky solution but, let us know if it works. If not we can keep noodling away at it!

 

 

 

Pragati11
Super User
Super User

HI @Anonymous ,

 

A quick question here. How you are importing this array to Power BI? Is this whole thing in a text file and then you are bringing it in POwer BI or some other file format?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hi @Pragati11 

 

Thank you for your reply.

I am using an ODBC connection to import this data into Power BI. 

Hi @Anonymous ,

 

ODBC connection to a database?

I am interested in knowing if this whole value is stored in a single column?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

It's not really a connection to a database, this situation is a little bit more complex.

 

The original data is stored in a nosql database in AWS. We use "Glue"" from AWS to put this data into "Athena". Afther this, I can import the data with an Simba Athena ODBC connection in Power BI. 

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

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.