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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors