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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
awap87
New Member

Loop Through Several Values, Change API Call URL and Insert Into Table

Hi,

First of all, sorry if the subject seems a little confusing.

I'm hoping to use the Dotmailer API to obtain some insights on email campaigns that I've sent (without having to login to the Dotmailer portal).

Using the Dotmailer API docs as a guide, I've pulled a complete list of all campaigns using the following call:

https://[region ID]-api.dotmailer.com/v2/campaigns

However, after checking the docs (and speaking to Dotmailer), if I wanted to pull any insights on the campaigns (opens, click through rate etc), this can only be done on a campaign by campaign basis using the following call:

https://[region ID]-api.dotmailer.com/v2/campaigns/[ID]/summary

Now, what I'm hoping to do is take each campaign ID returned from the first call, insert the ID column into a fresh table.

Then, I'd like to loop through each ID in the new table, update the URL for the 2nd call with each of the individual campaign ID's and insert the insights next to the correct campaign number.

Would this be possible at all?

Many thanks
1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @awap87,

 

It could be done. 

 

First, create a function using syntax like below.

let functionName = (param1 as datatype) =>
let
 Source = Json.Document(Web.Contents("https://[region ID]-api.dotmailer.com/v2/campaigns/" & param1 & "/summary").
in
 Source
in functionName

After you have inserted the ID column in to a new table, then you can add a custom column to the table that calls/invokes the function above. Smiley Happy

 

Reference:
http://datachix.com/2014/05/22/power-query-functions-some-scenarios/

http://satalyst.com/power-query-creating-a-parameterized-function-in-m/

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @awap87,

 

It could be done. 

 

First, create a function using syntax like below.

let functionName = (param1 as datatype) =>
let
 Source = Json.Document(Web.Contents("https://[region ID]-api.dotmailer.com/v2/campaigns/" & param1 & "/summary").
in
 Source
in functionName

After you have inserted the ID column in to a new table, then you can add a custom column to the table that calls/invokes the function above. Smiley Happy

 

Reference:
http://datachix.com/2014/05/22/power-query-functions-some-scenarios/

http://satalyst.com/power-query-creating-a-parameterized-function-in-m/

 

Regards

Anonymous
Not applicable

Hi @v-ljerr-msft,

 

I do have the similar requirment and was going through theis solution but I didnt understand where to write this function and  from where to call?  Sorry new to this  type of work.

 

Please advise.

 

Thanks

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors