Forum Discussion
LinkeLoutjes
2 years agoNew Member
How to research an expression.error converting null to text within functions
Hi,
Easy question probably, however since I'm just beginning... The following function takes a list from a helper query as a source. However there seems to be an issue converting null values.
2 Questions:
1. How to insert the variable example value "uris" in this example. So that I'm able to check the result? Now simply the query failes without being able to see where.
2. How to solve the Expresssion.Error: We cannot convert the value null to type Text for the following: (I'm looking more towards a strategy, not the exact solution)
let
Source = (uris as text) => let
Source = Json.Document(Web.Contents("https://api.spotify.com/v1/tracks" &"?ids=" & uris & "&market=" & DefaultConnCountry, [Headers=[Authorization="Bearer " & SpotifyAccessToken]])),
tracks = Source[tracks],
#"Converted to Table" = Table.FromList(tracks, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
// Sometimes Spotify returns a different ID if the country listened to is different from the DefaultConnCountry.
// To avoid songs not being matched, the following steps use the comma seperated list to match the songs with their inputted id.
#"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Index", 0, 1, Int64.Type),
#"URIs split" = Text.Split(uris,","),
#"Added original id" = Table.AddColumn(#"Added Index", "id", each #"URIs split"{[Index]}),
#"Expanded Column" = Table.ExpandRecordColumn(#"Added original id", "Column1", {"album", "artists", "duration_ms", "explicit", "name", "popularity"})
in
#"Expanded Column"
in
Source
Thanks!
1 Reply
- Syndicate_AdminAdministrator
Read about ?? (The Power Query equivalent of COALESCE).