Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

concatinated string to image url not working

I'm fetching data from openweathermap api. Then I'm trying to create image url string to fetch image:
```

ImageUrl = "https://openweathermap.org/img/wn/" & CALCULATE(
    FIRSTNONBLANK(Weather[list.weather.icon], 1),
    Weather[list.dt_txt] = MIN(WeatherWrzesnia[list.dt_txt])) & "@2x.png"
```
Image doesnt load, when printing ImageUrl to text field ive got 
```
```
after pasting that to browser I cant get image. In address input it's changing to 
```
```
After retyping manually to the browser url works. Powerbi somehow destroy my ulr.
  • Hi Anonymous ,

    if its returning this:

    https://openweathermap.org/img/wn/[email protected]

    its mean that your calculate is returning blank as result, lets breakdown this.

    1- I'm supposing that you're in WeatherWrzesnia table, where you want to create a calculated column ImageUrl.
    2- with this, you can create a new calculated column using this DAX:

    ImageUrl =
        "https://openweathermap.org/img/wn/" &
        CALCULATE(
            FIRSTNONBLANK(Weather[list.weather.icon], 1),
            FILTER(
                Weather,
                Weather[list.dt_txt] = WeatherWrzesnia[list.dt_txt]
            )
        ) &
        "@2x.png"

     

    I'm not using MIN function, because calculated columns works in row context also.

    let me now if this help you, try to debbug your DAX to see what the calculate returns.


4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    funny that after pasting invalid url here it validated. raport still not working tho

  • Hi Anonymous 

    Is this the output of your measure as a text?

    https://openweathermap.org/img/wn/[email protected]

     

    Because this loads fine in Power BI after changing  its data category to image URL. What is the result of this calculation?

    CALCULATE(
        FIRSTNONBLANK(Weather[list.weather.icon], 1),
        Weather[list.dt_txt] = MIN(WeatherWrzesnia[list.dt_txt]))

     

  • Hi Anonymous ,

    if its returning this:

    https://openweathermap.org/img/wn/[email protected]

    its mean that your calculate is returning blank as result, lets breakdown this.

    1- I'm supposing that you're in WeatherWrzesnia table, where you want to create a calculated column ImageUrl.
    2- with this, you can create a new calculated column using this DAX:

    ImageUrl =
        "https://openweathermap.org/img/wn/" &
        CALCULATE(
            FIRSTNONBLANK(Weather[list.weather.icon], 1),
            FILTER(
                Weather,
                Weather[list.dt_txt] = WeatherWrzesnia[list.dt_txt]
            )
        ) &
        "@2x.png"

     

    I'm not using MIN function, because calculated columns works in row context also.

    let me now if this help you, try to debbug your DAX to see what the calculate returns.


    • Anonymous's avatar
      Anonymous
      Not applicable

      Works, thank u