Excel can Convert JSON data to Table in Excel

%3CLINGO-SUB%20id%3D%22lingo-sub-1660398%22%20slang%3D%22en-US%22%3EExcel%20can%20Convert%20JSON%20data%20to%20Table%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660398%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EActually%20i%20am%20getting%20data%20from%20external%20source%20through%20API%20by%20using%20%22From%20Web%22%20option%20in%20excel%20%26amp%3B%20getting%20JSON%20data.%20But%20after%20getting%20data%20in%20excel%2C%20trying%20to%20transform%20that%20JSON%20data%20into%20Table%20by%20using%20power%20query.%20But%2C%20it%20is%20not%20working.%20JSON%20data%20is%20not%20transforming%20into%20proper%20table.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20pivot%2C%20transpose%20options%20in%20power%20query%2C%20still%20not%20working.%20Attached%20Excel%20for%20reference%20that%20what%20is%20required%20%26amp%3B%20what%20i%20am%20getting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20any%20solutions%20are%20available%20for%20this.%20Any%20insights%20are%20highly%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3ESridhar%20Dasari%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1660398%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20for%20web%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1660592%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20can%20Convert%20JSON%20data%20to%20Table%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660592%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F791266%22%20target%3D%22_blank%22%3E%40SridharDasari%3C%2FA%3E%26nbsp%3BNot%20sure%20how%20you%20connected%20to%20the%20JSON%20data%2C%20but%20I%20copied%20the%20table%20in%20columns%20A%20and%20B%20on%20the%20%22Actual%20Data%22%20sheet%20to%20columns%20E%20and%20F.%20then%20I%20created%20a%20fresh%20query%20on%20that%20table%20and%20loaded%20the%20end%20result%20into%20Sheet1.%20Looks%20like%20what%20you%20asked%20for.%20I%20hope%20this%20is%20helpful%20and%20trust%20you%20will%20be%20able%20to%20figure%20out%20what%20I%20did%20to%20create%20the%20output.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1661566%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20can%20Convert%20JSON%20data%20to%20Table%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1661566%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20got%20that%20JSON%20data%20by%20using%20an%20API%2C%20nothing%20more%20than%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20solution%2C%20the%20solution%20you%20provided%20is%20exactly%20what%20i%20needed.%20But%2C%20i%20need%20to%20know%20why%20you%20copied%20the%20columns%20A%20%26amp%3B%20B%20to%20columns%20E%20%26amp%3B%20F.%20Why%20don't%20you%20do%20on%20the%20columns%20i%20have%20given.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20in%20original%20columns%20it%20is%20not%20working.%20Will%20you%20please%20elaborate%20how%20can%20i%20proceed%20with%20that.%26nbsp%3BLet%20me%20know%20if%20any%20issues%20if%20we%20do%20on%20the%20same%20columns.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3ESridhar%20Dasari%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1661645%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20can%20Convert%20JSON%20data%20to%20Table%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1661645%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F791266%22%20target%3D%22_blank%22%3E%40SridharDasari%3C%2FA%3E%26nbsp%3BWhen%20I%20worked%20on%20my%20initial%20answer%20I%20had%20some%20error%20messages%20form%20the%20original%20data.%20Can't%20remember%20exactly%20what.%20Didn't%20have%20much%20time%20so%20decided%20to%20just%20copy%20it%20to%20get%20a%20clean%20start%2C%20assuming%20you%20would%20be%20able%20to%20adopt%20my%20query%20to%20your%20own%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%2C%20I%20had%20a%20chance%20to%20apply%20the%20same%20steps%20to%20your%20original%20data%2C%20called%20%22Table5%22.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1661708%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20can%20Convert%20JSON%20data%20to%20Table%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1661708%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWill%20you%20please%20update%20the%20steps%20that%20you%20have%20done%20now.%20Because%20query%20looks%20same%20as%20original.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3Elet%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3ESource%20%3D%20Excel.CurrentWorkbook()%7B%5BName%3D%22%3CFONT%20color%3D%22%23339966%22%3ETable1_2%3C%2FFONT%3E%22%5D%7D%5BContent%5D%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%23%22Changed%20Type%22%20%3D%20Table.TransformColumnTypes(Source%2C%7B%7B%22CommitmentID%22%2C%20type%20text%7D%2C%20%7B%22CommitmentName%22%2C%20type%20text%7D%2C%20%7B%22Type%22%2C%20type%20text%7D%2C%20%7B%22Hours%22%2C%20Int64.Type%7D%2C%20%7B%22CommittedCost%22%2C%20Int64.Type%7D%2C%20%7B%22ActualCost%22%2C%20Int64.Type%7D%2C%20%7B%22OpenCommitment%22%2C%20Int64.Type%7D%7D)%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3Ein%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%23%22Changed%20Type%22%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20above%20code%20it%20is%20showing%20%22Table1_2%22%20not%20%22Table5%22(Highlighted).%20So%20please%20give%20me%20the%20steps%20what%20you%20done.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi,

 

Actually i am getting data from external source through API by using "From Web" option in excel & getting JSON data. But after getting data in excel, trying to transform that JSON data into Table by using power query. But, it is not working. JSON data is not transforming into proper table.

 

I have tried pivot, transpose options in power query, still not working. Attached Excel for reference that what is required & what i am getting.

 

Let me know if any solutions are available for this. Any insights are highly appreciated.

 

Thanks

Sridhar Dasari

6 Replies

@SridharDasari Not sure how you connected to the JSON data, but I copied the table in columns A and B on the "Actual Data" sheet to columns E and F. then I created a fresh query on that table and loaded the end result into Sheet1. Looks like what you asked for. I hope this is helpful and trust you will be able to figure out what I did to create the output.

 

 

Hi @Riny_van_Eekelen ,

 

I have got that JSON data by using an API, nothing more than that.

 

Thanks for your solution, the solution you provided is exactly what i needed. But, i need to know why you copied the columns A & B to columns E & F. Why don't you do on the columns i have given.

 

I have tried in original columns it is not working. Will you please elaborate how can i proceed with that. Let me know if any issues if we do on the same columns.

 

Thanks

Sridhar Dasari

 

@SridharDasari When I worked on my initial answer I had some error messages form the original data. Can't remember exactly what. Didn't have much time so decided to just copy it to get a clean start, assuming you would be able to adopt my query to your own file.

 

Now, I had a chance to apply the same steps to your original data, called "Table5".

Thanks @Riny_van_Eekelen 

 

Will you please update the steps that you have done now. Because query looks same as original.

 

let
Source = Excel.CurrentWorkbook(){[Name="Table1_2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CommitmentID", type text}, {"CommitmentName", type text}, {"Type", type text}, {"Hours", Int64.Type}, {"CommittedCost", Int64.Type}, {"ActualCost", Int64.Type}, {"OpenCommitment", Int64.Type}})
in
#"Changed Type"

 

In the above code it is showing "Table1_2" not "Table5"(Highlighted). So please give me the steps what you done.

 

Thanks

@SridharDasari "Table1_2" is the name of the table that gets loaded back into Excel. If you want to change the data types, just add a step at the end of the query that generates the output table. Done that in the attached file.

 

In summar,y all that the query does is:

 

1. Connect to the data table called "Table5"

2. Trim and clean both columns to get rid of trailing and/or leading spaces and possible other "strange" characters

3. Add an index column and filter out rows that have no data ("null") in Column1

4. Pivot Column1 with values from from Column2 (Don't aggregate in Advance options)

5. Fill up the six last columns

6. Filter "null" from the CommentID column

7. Remove the index

8. Change data types

 

Close and load to a table in Excel.

 

 Does this answer your questions?

Thanks @Riny_van_Eekelen for your solution & your valuable time.