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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Tomek1982
Helper I
Helper I

invoke custom function

Hi, 

I try to invoke a custom function.

Tomek1982_0-1733479371383.png

 

While digging into a case I found that this seems to be related to reading files from sharepoint.
There are 3 files

Tomek1982_0-1733484996959.png

And a simple function:

Tomek1982_1-1733485139401.png

which for some files is not working properly not finding file

Tomek1982_2-1733485225000.png

Tomek1982_3-1733485252672.png

 

5 REPLIES 5
PwerQueryKees
Super User
Super User

Apologies, I did not properly read you problem description.

I did so now...

What you are trying to do is very doabale and I have a lot of experience with processing sharepoint files.
It does need debugging.

What I normally do is to replace the "in" clause of the function that is giving trouble with the and intermediairy steps until I found the issues. This way you can see where it goes wrong and you can gradually develop your function.

Like

 

 

let 
   x = 1,
   y = 2,
   result = x + y
in
   X

 

 

As a first, I would like to see the output of the "Filtered Rows1" step.

 

Common cause for mismatches in filtering are:

  • Case Sensitivity
    A <> a
    Does not seem to be the problem here.
  • Extra spaces at the end or in the middle
    They are hard to spot, so can't tell if this could be your problem
  • What you try to filter down is not what you expect it to be.
    A row that not exist in the first place will never show up after a filter 🙂

In adition I have some immediate questions:

how was the result below produced?

PwerQueryKees_0-1733499568037.png

In the above result, if you click in the white space to the right of the word Table, What shows up at the bottom of the screen?

Why is there a "Filtered Rows1 step in here?

PwerQueryKees_1-1733499650149.png

 

AND

I would take a slightly different approach (I don't have access to sharepoint at the moment, so there may be small mistakes):

  • Take your list of filenames (like the screenshot with the survey temp column) 
  • Add a column to construct the complete filename
  • Make a separate query with the Sharepoint.Files result.
    Filer and massage it anyway you want.
    Make sur eyou get only files from the folder you want to take as input.
  • Merge "List of Filenames" with "Sharepoint Files" on the filename column
  • Expand the Content column (from the top of my head)
  • Change your "Grab" function
    • to expect a binary parameter
    • remove the steps you showed in the screenshot
  • Add a column to the result of the merge like below where 

 

= Table.AddColumn(#"Changed Type", "Survey result", each #"Survey result grab"([Sharepoint Files.Content]))​​

 

This wil also save you repeating calls to Sharepoint.Files() which can be very slow on large sharpoint sites.

Hope this helps...

@PwerQueryKees 

 

Thanks for support. I am preetu sure it is a bug in a Power BI. I wrote the function to compare filename with calculated filename.

For some files it is working fine

Tomek1982_0-1733517923081.png

and for some it is not

Tomek1982_2-1733517979144.png

I copied both values from 2nd row to column in excel and I removed duplicates. Those cells are equal, and comparision is not working fine. On a screen there are different types, but it does not change anything.

Hm. I find it highly unlikely this is a bug in powerquery. Comparisons are fundamental for the reliability of PowerQuery. I have not heard anyone else about this bug or encountred it myself.

My proffesor in college always said: "don't blame the compiler, debug your program."

The screenshots you send show something, but without seeing all the M code leading to it, I can not help you. In your situation I would start with trying to replicate the issue with local files (with Folder.File()). I could try this as well...

And try some of the tips I gave you earlier.

The quicker method is probably to use my suggestion to solve this with a merge though. This has other benefits as well.

PwerQueryKees
Super User
Super User

Here is your problem:

PwerQueryKees_1-1733481941485.png

Change to:

= Table.AddColumn(#"Changed Type", "Survey result", each #"Survey result grab"([Survey result]))

@PwerQueryKees  I do not think so [Survey temp] is a column with parameters to pass to the function. This part is correct. Anyway when I changed as you advised there was an error 

Tomek1982_0-1733483095639.png

 

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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