Forum

How can I filter a ...
 
Notifications
Clear all

How can I filter a query based on a List of UIDs

7 Posts
2 Users
0 Reactions
87 Views
(@dzabaldano)
Posts: 4
Active Member
Topic starter
 

The base program is called Aries and all of the data is housed on a SQL server. While working in the program (Aries) it creates different tables for different analysis & links them based on the "Property Table" that houses a UID to link all tables

For an idea of the amount of rows I'm dealing with the "Property Table" for this database has 28,681 rows. I have filtered those rows down to 3,230 based on the data I want to analyze. I've created a list of those 3,230 UIDs.

The "Detail Table" containing monthly data that has 615,802 rows for the whole database. How can i create a relationship to my list of UIDs? 

 
Posted : 21/08/2020 11:17 am
(@mynda)
Posts: 4762
Member Admin
 

Hi Daniel,

Welcome to our forum!

If you're loading the data from Power Query to Power Pivot then the relationship is created in Power Pivot. If you want to bring data from the UIDs table to the Detail table (like a VLOOKUP in Excel) before loading to Power Pivot then you can do this by merging the two tables.

Hope that points you in the right direction.

Mynda

 
Posted : 21/08/2020 9:11 pm
(@dzabaldano)
Posts: 4
Active Member
Topic starter
 

Thanks Mynda, I'm super excited about utilizing this new to me resource!

I was able to create the relationship in Power Pivot between the "Property Table" (dim) and the Detail Table like you suggested. Now I need to bring in daily numbers from a different database. If i do the same method I will be loading over 4 millions rows for the time period I need.  

Using Excel 365 & I attached a sample file

Here is my objective:

Since I am able to create a DimTable and filter the table down to the required data set. I think I should be able to reference that query and make a dynamic list of APIWellNumbers to filter down the Daily Records. This way I will not have to bring the entire table into power pivot and then filter off the relationship.

 

I've tried all afternoon and this is the best syntax I could come up with from google. I just can't make it work

#"Filter Rows by Dynamic List"= Table.SelectRows(Source, each List.Contains(APIFiltered,[APIWellNumber]))

 
Posted : 22/08/2020 6:12 pm
(@mynda)
Posts: 4762
Member Admin
 

Hi Daniel,

Please see lesson 7.01 of the Power Query course on Parameter Tables for Filtering. If you're still stuck, come back with your file showing your attempt and I can help you further.

Mynda

 
Posted : 23/08/2020 1:20 am
(@dzabaldano)
Posts: 4
Active Member
Topic starter
 

Attached is a sample data set with my second attempt. I was able to make the parameter work but for only a single entry from a pasted list. I'm trying to limit the number of Distinct APIWellNumbers in the daily table from ~3,400 to match the DimTable's of 981 and then create a table of their daily production. 

I understand that this can be done in power pivot for this data set. The SQL server I will be pulling these daily numbers from holds all APIWellNumbers for the entire company. To keep the refresh time reasonable I need a way to filter from a dynamic list of desired APIs instead of bringing in the whole table into Power Pivot and then filtering.  

 
Posted : 23/08/2020 12:10 pm
(@mynda)
Posts: 4762
Member Admin
 

Hi Daniel,

If you want to filter by multiple parameters you need to create a list, which you've done with APIFiltered, then you can use the List.Contains function in the FactTable_Parameter-Pasted query. In the last step of that query, Filtered Rows, use this formula:

= Table.SelectRows(#"Removed Columns", each List.Contains(APIFiltered , [APIWellNumber]))

i.e. where the APIFiltered list contains the ID in the APIWellNumber column of the FactTable_Parameter-Pasted query.

Hope that helps.

Mynda

 
Posted : 23/08/2020 11:58 pm
(@dzabaldano)
Posts: 4
Active Member
Topic starter
 

I was dancing all around that syntax but couldn't get the order right. Thank you

 
Posted : 24/08/2020 10:59 am
Share: