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 September 15. Request your voucher.

Reply
btardo01
New Member

using a cell value to filter a power query

I have a table that is generated from a power BI dataset and returns a table as follows:

 

Organization[OpCo]Clients[Client Code]
AlabamaABCINC
AlabamaFASTTRA

 

You'll see the line that reads:

TREATAS({"Alabama"}, 'Organization'[OpCo])

 

I would like "Alabama" to be a variable based on either:

  1. user selection on a separate tab called "Dashboard" in Cell A1     OR 
  2. function called "Choose_OpCo()"

The goal is that when the user changes the OpCo in cell A1 on the Dashboard tab, this table will update with the new information for the OpCo that was selected.

DEFINE
    VAR __DS0FilterTable = 
        TREATAS({"Alabama"}, 'Organization'[OpCo])

    VAR __DS0Core = 
        SELECTCOLUMNS(
            KEEPFILTERS(
                FILTER(
                    KEEPFILTERS(
                        SUMMARIZECOLUMNS(
                            'Organization'[OpCo],
                            'Clients'[Client Code],
                            __DS0FilterTable,
                            "CountRowsFactPolicy", COUNTROWS('FactPolicy')
                        )
                    ),
                    OR(
                        NOT(ISBLANK('Organization'[OpCo])),
                        NOT(ISBLANK('Clients'[Client Code]))
                    )
                )
            ),
            "'Organization'[OpCo]", 'Organization'[OpCo],
            "'Clients'[Client Code]", 'Clients'[Client Code]
        )

    VAR __DS0BodyLimited = 
        TOPN(500000, __DS0Core, 'Organization'[OpCo], 1, 'Clients'[Client Code], 1)

EVALUATE
    __DS0BodyLimited

ORDER BY
    'Organization'[OpCo], 'Clients'[Client Code]

 

1 REPLY 1
MFelix
Super User
Super User

Hi @btardo01 ,

 

You need to have the values you want to select on a separate table and then you can change the code of the {Alabama} by VALUES(Table[Column]) this will allow to have a dynamic content on that treatas function.

 

But be carefull that this is for a calculation measure you cannot create an actual table on your model that is variable based on the input of the user on a report value.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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