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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Amar-Agnihotri
Resolver I
Resolver I

We cannot convert a value of type Record to type Function.

Hi,

I have created a function to call Activity events REST api to get user activity for the last 30 days. FOe Bearer Access token i have created another function. Here is the code -

 

Get Access Token 

AmarAgnihotri_0-1655119870960.png

 

Function is working fine and generating bearer access token as shown 

AmarAgnihotri_1-1655119916981.png

 

Now to get User Activity data using Activity events api i have created a list of dates and two custom columns for startdate and enddate as 

AmarAgnihotri_2-1655119979810.png

 

Now i have created another function GetActivity to call REST API as - 

AmarAgnihotri_3-1655120031876.png

 

Now i am adding a custom column in a query to generate the list of user activity data by making a call of this custom function as

 

AmarAgnihotri_4-1655120096593.png

In the above snap it is clear that Get Activity function is calling Get Access token function inside to get the Bearer access token and it is picking up the startdate and enddate from the columns defined above , Noiw it should a list activity as shown -

 

AmarAgnihotri_5-1655120183291.png

 

But in my case it is showing this error -

 

AmarAgnihotri_6-1655120215407.png

Can anyone help my out to resolve this . I am following Bi Elite video to crteate an admin panel -

This is the link of video 

https://www.youtube.com/watch?v=Z4E2jSZ4r6A&list=PLL-WSn9hvefogtxxi7CJhjLCJvrDY0mpQ&index=4

 

and this is the link of the M code  - 

 

https://bielite.com/blog/building-a-power-bi-admin-report/

 

 

Thanks in advance 

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Amar-Agnihotri 

 

The only difference I can see is in your Get Activity Function

token = Source(continuationToken),

which should be

token = Source[continuationToken],

View solution in original post

4 REPLIES 4
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Amar-Agnihotri 

 

The only difference I can see is in your Get Activity Function

token = Source(continuationToken),

which should be

token = Source[continuationToken],

Hi @Vera_33 ,

You are right. That was a silly mistake and now eveything is working fine. You are like an angel for me. Thanks a lot sister 🙂

Hi @Amar-Agnihotri 

 

Good practice to type out instead of copy paste all the M code, for the naming of custom function, my personal habit is to prefix with "fx" or "fn", and no space, so it is easier to debug...

Thanks 😊

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors