The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello
I want to parse a dynamic Column Name to a Table.SelectRows so that I can switch which column to apply a row filter.
Is that possible? Tried several things but had to resolve to unpivoting to filter.
Thanks!
Hi, @Anonymous ,
I just encountered the same question working with Power Query for excel and found your post. I expect the object models to be very similar, but would recommend testing for each environment. While I am by no stretch an export, I agree that "It's not supported" is an inadequate answer.
The syntax for the method in Excel has the following structure, with an example of a condition of Text.Contains satisfying the request:
Table.SelectRows(TableRef as table, each Text.Contains([FixedFieldName], ConditionValue as text)
There are two things worth noting here. First, the "each" operator is generating an iterative reference for every row in the table. Second, the [FixedFieldName] appears at first glance to refer to the field value in the table, but is instead being applied to the object returned by the "each" iterator. With this in mind, the dynamic Column Name should be accessible through the correct object interface. Again, this may vary for PowerBI, but is hopefully similar.
The most appropriate object available in excel for an iterated row is the Record object. Updating our previous example provides the following:
Table.SelectRow(TableRef as table, each Text.Contains(Record.Field((_), ColumnName as text), ConditionValue as text)
In PowerQuery, this can be packaged as a custom function, and reused with a call similar to TableContains(TableRef, ColumnName, ConditionValue).
I hope you and others find this helpful in fighting with the object model.
Best regards.
Thanks but that is not adequate. I need to have a text parameter that will be fed into Table.SelectRows, is that possible please?
Hi, @Anonymous
Are you referring to parameterizing the specified columns and filter criteria to filter data dynamically?
Sorry, I'm afraid it's not currently supported.
Best Regards,
Community Support Team _ Eason
@Anonymous ,Table.ColumnNames can give you list of column names, if that can help in some way
https://learn.microsoft.com/en-us/powerquery-m/table-columnnames