Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
4 years ago
Solved

Modify table that a SUMX points to

Hello good afternoon I hope you can help me. It is possible that in a function of the STYLE of SUMX you can dynamically modify the table in which you make the sum, something like VAR _a = "test" ...
  • liuqi_pbi's avatar
    4 years ago

    Hi Yeztrom 

     

    The table expression cannot be dynamic. Instead, you can create 4 measures for the switch with different table names in them. For example, 

    Total1 = SUMX('table1',[field])
    
    Total2 = SUMX('table2',[field])
    
    Total3 = SUMX('table3',[field])
    
    Total4 = SUMX('table4',[field])

     

    Then create a switch measure based on different conditions:

    Result =
    SWITCH (
        TRUE (),
        condition1, [Total1],
        condition2, [Total2],
        condition3, [Total3],
        condition4, [Total4]
    )

     

    Hope this helps

     

    ----------------------------------------------------------------------

    If this reply helps solve the problem, please mark it as Solution! Kudos are appreciated too!