Forum Discussion
Hoe to get a value from JSON
- Anonymous2 years ago
Hi ,
Please try:List.Select(Json.Document([ratings_and_unit_endorsements]),(record) => record[unit] = [unit]){0}[expiry_date]
All steps:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUUqtKMgsqoxPSSxJjVGyilEyMjAy1jU01DWyjFHSiVEqSizJzEsHyzi6eIKFSvMyS8ACrhGRkTFKtTp4TDE2wDAlIBjVFH/fiAi8phjpGhgSNMUnxN8faEqskg6YqRQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ratings_and_unit_endorsements = _t, unit = _t]), AddExpiryDate = Table.AddColumn(Source, "Expiry Date", each List.Select(Json.Document([ratings_and_unit_endorsements]),(record) => record[unit] = [unit]){0}[expiry_date])in AddExpiryDateBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
I'm able to get the desired result with the following:
Table.AddColumn(#"Inserted JSON", "expiry_date", each try
if
Record.Field([JSON]{0}, "unit") = [unit] and
Record.Field([JSON]{0}, "rating") = [rating]
then Record.Field([JSON]{0}, "expiry_date")
else if
Record.Field([JSON]{1}, "unit") = [unit] and
Record.Field([JSON]{1}, "rating") = [rating]
then Record.Field([JSON]{1}, "expiry_date")
else if
Record.Field([JSON]{2}, "unit") = [unit] and
Record.Field([JSON]{2}, "rating") = [rating]
then Record.Field([JSON]{2}, "expiry_date")
else if
Record.Field([JSON]{3}, "unit") = [unit] and
Record.Field([JSON]{3}, "rating") = [rating]
then Record.Field([JSON]{3}, "expiry_date")
else if
Record.Field([JSON]{4}, "unit") = [unit] and
Record.Field([JSON]{4}, "rating") = [rating]
then Record.Field([JSON]{4}, "expiry_date")
else false
otherwise "")
This can probably be done better without hardcoding the indexes but I don't know how. Any ideas?
- Anonymous2 years agoNot applicable
Hi ,
Please try:List.Select(Json.Document([ratings_and_unit_endorsements]),(record) => record[unit] = [unit]){0}[expiry_date]
All steps:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUUqtKMgsqoxPSSxJjVGyilEyMjAy1jU01DWyjFHSiVEqSizJzEsHyzi6eIKFSvMyS8ACrhGRkTFKtTp4TDE2wDAlIBjVFH/fiAi8phjpGhgSNMUnxN8faEqskg6YqRQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ratings_and_unit_endorsements = _t, unit = _t]), AddExpiryDate = Table.AddColumn(Source, "Expiry Date", each List.Select(Json.Document([ratings_and_unit_endorsements]),(record) => record[unit] = [unit]){0}[expiry_date])in AddExpiryDateBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum