Forum Discussion

afaro's avatar
afaro
Helper III
2 years ago
Solved

Creating dynamic table with SELECTEDVALUE?

Is it possible to create dynamic tables this way?  I have written dax for creating tablewhich works perfectly fine when I manually provide the filters (which then makes it a static table) but when I...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi afaro ,

    I created a sample pbix file(see the attachment), please check if that is what you want.

    Added products = 
    VAR _month =
        SELECTEDVALUE ( 'Date'[Month] )
    VAR table1 =
        CALCULATETABLE (
            VALUES ( 'Data'[Product] ),
            FILTER ( 'Data', 'Data'[Month] = _month )
        )
    VAR table2 =
        CALCULATETABLE (
            VALUES ( 'Data'[Product] ),
            FILTER ( 'Data', 'Data'[Month] = _month - 1 )
        )
    VAR _tab =
        EXCEPT ( table1, table2 )
    RETURN
        CONCATENATEX ( _tab, [Product], "," )

    Best Regards