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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dslForPBI
Helper I
Helper I

How to call a function from "n" times

After struggling with this, seems I need a different approach..looking through several examples I still haven't found one which totally fits.  I am trying to filter a table based on values in a list.  I want the values I am filtering on to be checked from the list so i am thinking have a function which starts at the begining and iterates through to the end.  In short, i want to check the table (column "X") for a value in list "Y" as part of the filter.  Here is code snippet with what works currently (hardcoded) and what I want to do:

 


//Tried to use "ValueList" which is just a list of values to filter on...

//
//Hardcoded list works (below).. 

//
tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains({543,95,96,1359,1360,1104,1170,1172,93,1248,454,1361,92,97,-4,-3,-5,-7,-8,-2}, [Outstate_Code])),

//
//...but ValueList which is a list of these numbers does not (produces an empty table result)...it produces an empty result

tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains(Value,[Outstate_Code])),

 

..so perhaps some kind of function taking the number of items in the list and moving from top to bottom might work?

1 ACCEPTED SOLUTION

Hi @dslForPBI,

 

I'm glad to hear that you have resolved your issue. Please kindly mark your solution as Answer. It will help others with relevant issues find the answer more easily. Smiley Happy

 

Thanks,
Xi Jin.

View solution in original post

3 REPLIES 3
v-xjiin-msft
Solution Sage
Solution Sage

Hi @dslForPBI,

 

I have made some test. However the Power Query expression works fine. Please refer to my sample:

 

Source table and the list are like:

 

1111.PNG2222.PNG

 

Then define the expression for the source table:

 

3333.PNG

 

As you can see, it works. Thus in your scenario, could you please share us pbix file with OneDrive or something else if possible? So I can dig deeper and make some proper tests. If you can't share us your report, could you please share us some detailed screenshots or some sample data which can help us repro your issue?

 

Thanks,
Xi Jin.

Hello v-xjin-msft,

 

I was having issues but seems they were solved in another section on this forum.  What causes issues--it seems at least in my tests was referencing a list as a parameter.  The option that made it work was changin from "List.Contains" to "List.ContainsAny".

Hi @dslForPBI,

 

I'm glad to hear that you have resolved your issue. Please kindly mark your solution as Answer. It will help others with relevant issues find the answer more easily. Smiley Happy

 

Thanks,
Xi Jin.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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