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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
alpb
Frequent Visitor

Split dictionary values into columns

I would like to split these dictionaries one into its own column, with only the values inside.

For instance:

No.  | square | insights | api_token | messaging | reporting

1      |  null      | null         | null       | null             | null

2      |  false     | true        | false     | true             | false

3.     |  false     | true        | false     | true             | null

alpb_0-1628766645252.png

The additional problem that adds to complexity is that not all of the rows start with the same value. 

Some values start with "square", some others start with "messaging", and so on.

 

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

@alpb 

You can do this in power query by 

1. remove {}

2. split column on ,

3. add an index row

4. unpivot all but the index row

5. remove the Attribut column

6. split the Value on :

7 pivot value.1 column showing value.2 without any aggregation.

jdbuchanan71_0-1628768584131.png

jdbuchanan71_1-1628768599172.png

I have attached my sample file for you to look at.  Just right click on the table and select "edit query" to see the steps.

 

 

 

View solution in original post

Hi  @alpb ,

 

unpivot all but the index row --> in this step, if I have other columns, let's say "name, job title", do I also include these 2 columns in the unpivot stage?

Yes.

could you please explain more about step 7? i am not sure how to do that. There is a pivot column functionality, but how do I choose to show value or do one without any aggregations?

Pivoting column Value.1 according on values from Value.2 using "not aggregated" based on index column:

vkellymsft_0-1629098314201.png

Then you will get the result you need.

 

Best Regards,
Kelly

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

View solution in original post

6 REPLIES 6
jdbuchanan71
Super User
Super User

@alpb 

You can do this in power query by 

1. remove {}

2. split column on ,

3. add an index row

4. unpivot all but the index row

5. remove the Attribut column

6. split the Value on :

7 pivot value.1 column showing value.2 without any aggregation.

jdbuchanan71_0-1628768584131.png

jdbuchanan71_1-1628768599172.png

I have attached my sample file for you to look at.  Just right click on the table and select "edit query" to see the steps.

 

 

 

4. unpivot all but the index row --> in this step, if I have other columns, let's say "name, job title", do I also include these 2 columns in the unpivot stage?

could you please explain more about step 7? i am not sure how to do that. There is a pivot column functionality, but how do I choose to show value or do one without any aggregations?

Hi  @alpb ,

 

unpivot all but the index row --> in this step, if I have other columns, let's say "name, job title", do I also include these 2 columns in the unpivot stage?

Yes.

could you please explain more about step 7? i am not sure how to do that. There is a pivot column functionality, but how do I choose to show value or do one without any aggregations?

Pivoting column Value.1 according on values from Value.2 using "not aggregated" based on index column:

vkellymsft_0-1629098314201.png

Then you will get the result you need.

 

Best Regards,
Kelly

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

Mohammad_Refaei
Solution Specialist
Solution Specialist

In power query split column by delimiter... you may share sample data in text format to send you a sample file .

the split column by delimiter function will only result like this
No. column_name1 column_name2
1      search2: true        app_shell: true

2      square:false          insights: true

Yes... we will need to do further processing like pivoting unpivoting

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.