cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Bokangmaela
Frequent Visitor

Power BI Custom connector

Good day, 

 

I have built a custom connector in visual studio to connect to a custom datasource. I am however struggle adding and IF statement in the function as I see that it indicates an error when I add one. Here is a simple code snipt of that I am trying to do. 

 

Connect = (url as text, count as number) =>
let   

If count< 1 then samplecount = 1 else samplecount= count,
response = Json.Document( Web.Contents(url, [ samplecount]))
in
response;

 

I am not sure if it is a limitation of the PowerBI connector SDK or I am not following the examples online correctly. Please share same insight if possible. 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Bokangmaela 

 

Try changing the first statement into below:

 

samplecount = If count < 1 then 1 else count,

 

The second statement also has an error. Web.Contents function expects to have a record parameter after the url. The samplecount should be passed to a valid field in the record. Web.Contents - PowerQuery M | Microsoft Learn

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Bokangmaela 

 

Try changing the first statement into below:

 

samplecount = If count < 1 then 1 else count,

 

The second statement also has an error. Web.Contents function expects to have a record parameter after the url. The samplecount should be passed to a valid field in the record. Web.Contents - PowerQuery M | Microsoft Learn

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

That worked, thanks a lot!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors