Forum Discussion

jjortons's avatar
jjortons
New Member
1 year ago
Solved

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"}})
)

 

 
  • Fowmy's avatar
    Fowmy
    1 year ago

    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

3 Replies

  • Fowmy's avatar
    Fowmy
    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

    • jjortons's avatar
      jjortons
      New Member

      thanks!

      it seems this is not possible atm, then?

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

       

       

      • Fowmy's avatar
        Fowmy
        Super User

        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