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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
jjortons
New Member

dynamically return tables based on selectedvalue

How can I return different unioned tables depending on a SELECTEDVALUE() variable using below? tyia!

tbl_generic =
var tbl1 =
CALCULATETABLE(
    SELECTCOLUMNS(
        'production product',
        "idx", 'production product'[productid],
        "productname", 'production product'[name]
    )
)

 

var tbl1 =
CALCULATETABLE(
    SELECTCOLUMNS(
        'product',
        "idx", 'product'[productid],
        "productname", 'product'[name]
    )
)
var tbl2 =
CALCULATETABLE(
    SELECTCOLUMNS(
        'category',
        "idx", 'category'[categoryid],
        "categoryname", 'category'[name]
    )
)


var x = 1 // will be from a SELECTEDVALUE()
var _tbl = if(x= 1, tbl1, tbl2)

return
UNION(
    _tbl,
    DATATABLE("idx", INTEGER, "xyz", STRING, {{-1, "Others"}})
)

 

 
1 ACCEPTED SOLUTION

@jjortons 

Yes, it's not possible, you need to create the required tables and the measures. you may use field parameters to swich measures on the report

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
Fowmy
Super User
Super User

@jjortons 
While creating a table or calculated column in Power BI, capturing slicer selections in real-time isn't feasible. Power BI constructs tables and columns before making them available on the report canvas.  Create seperate measures and call them based on selection

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

thanks!

it seems this is not possible atm, then?

my intention was to create a generic table of sorts based on another visual selection.

 

 

@jjortons 

Yes, it's not possible, you need to create the required tables and the measures. you may use field parameters to swich measures on the report

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.