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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
LinkeLoutjes
New 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 1
Syndicate_Admin
Administrator
Administrator

Read about ??  (The Power Query equivalent of COALESCE).

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors