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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
FabioRCampos
Regular Visitor

You can't schedule refresh for this semantic model because - Custom Power Query Script

I recently published a dashboard, and among the data sources, there was a custom query as shown below:

 

 

 

let
// Defina a lista de moedas que deseja consultar
ListaMoedas = {"USD-BRL", "PEN-BRL","ARS-BRL","COP-BRL","CLP-BRL","MXN-BRL","EUR-BRL","PEN-USD","ARS-USD","COP-USD","CLP-USD","MXN-USD","BRL-USD","EUR-USD"}, // Adicione mais moedas conforme necessário

// Calcule as datas dinâmicas
DataHoje = Date.From(DateTime.LocalNow()),
DataInicio = Date.AddDays(DataHoje, -30),
DataHojeTexto = Date.ToText(DataHoje, "yyyyMMdd"),
DataInicioTexto = Date.ToText(DataInicio, "yyyyMMdd"),

// Função para obter dados da API para uma moeda específica
GetDadosMoeda = (Moeda as text) =>
let
URL = "https://economia.awesomeapi.com.br/json/daily/" & Moeda & "/?start_date=" & DataInicioTexto & "&end_date=" & DataHojeTexto,
Fonte = Json.Document(Web.Contents(URL)),
Tabela = Table.FromList(Fonte, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
ExpandeColunas = Table.ExpandRecordColumn(Tabela, "Column1", {"code", "codein", "name", "high", "low", "varBid", "pctChange", "bid", "ask", "timestamp", "create_date"}, {"Code", "Codein", "Name", "High", "Low", "VarBid", "PctChange", "Bid", "Ask", "Timestamp", "CreateDate"}),
AdicionaMoeda = Table.AddColumn(ExpandeColunas, "Moeda", each Moeda)
in
AdicionaMoeda,

// Combine os dados de todas as moedas
DadosCombinados = Table.Combine(List.Transform(ListaMoedas, each GetDadosMoeda(_))),
#"Tipo Alterado com Localidade" = Table.TransformColumnTypes(DadosCombinados, {{"CreateDate", type datetime}}, "en-US"),
#"Tipo Alterado" = Table.TransformColumnTypes(#"Tipo Alterado com Localidade",{{"CreateDate", type date}})
in
#"Tipo Alterado"

 

When I tried to schedule the updates (Power BI Services), it displayed the following error:

FabioRCampos_0-1718021693050.png

 

Within Power BI, in the data source settings (Pbix file), I also have this information:

FabioRCampos_1-1718021723584.png

 

FabioRCampos_3-1718021758803.png

 

How do I resolve this?

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Implement the correct Power Query code, using RelativePath and Query.

 

Web.Contents - PowerQuery M | Microsoft Learn

View solution in original post

v-yohua-msft
Community Support
Community Support

Hi, @FabioRCampos 

Make sure that the Power BI service has the credentials required to access the external APIs. This typically involves configuring the data gateway and ensuring that the Power BI service is using the correct credentials and has the necessary permissions. For more information about setting up data source credentials, see:

Configure scheduled refresh - Power BI | Microsoft Learn

 

If the API is considered an on-premises data gateway from a Power BI service perspective, you may need an on-premises data gateway to facilitate connectivity. Make sure that the gateway is properly installed, configured, and linked to the Power BI service. For detailed steps to set up an on-premises data gateway, visit On-premises data gateway:

Configure scheduled refresh - Power BI | Microsoft Learn

 

Power BI requires you to configure a privacy level for your data source to control how your data is combined. Incorrect privacy level settings may prevent the refresh operation.  You can check the following link:

Solved: Some data sources may not be listed because of han... - Microsoft Fabric Community

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yohua-msft
Community Support
Community Support

Hi, @FabioRCampos 

Make sure that the Power BI service has the credentials required to access the external APIs. This typically involves configuring the data gateway and ensuring that the Power BI service is using the correct credentials and has the necessary permissions. For more information about setting up data source credentials, see:

Configure scheduled refresh - Power BI | Microsoft Learn

 

If the API is considered an on-premises data gateway from a Power BI service perspective, you may need an on-premises data gateway to facilitate connectivity. Make sure that the gateway is properly installed, configured, and linked to the Power BI service. For detailed steps to set up an on-premises data gateway, visit On-premises data gateway:

Configure scheduled refresh - Power BI | Microsoft Learn

 

Power BI requires you to configure a privacy level for your data source to control how your data is combined. Incorrect privacy level settings may prevent the refresh operation.  You can check the following link:

Solved: Some data sources may not be listed because of han... - Microsoft Fabric Community

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Implement the correct Power Query code, using RelativePath and Query.

 

Web.Contents - PowerQuery M | Microsoft Learn

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.