Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Switch function not working as intended

Hi All , Im trying to use switch function to dynamically change the columns displayed in a matrix as below   How ever when I use it on my filter , Im only seeing the 1st measure dynamically ....
  • v-kkf-msft's avatar
    4 years ago

    Hi Anonymous ,


    First please create a new table containing the names of these measures.

     

    Then create the following measures and filter the matrix visual.

     

    Mapping = 
    SWITCH (
        MAX ( MatrixColumns[Measure Name] ),
        "Total Orders", [Total Orders],
        "CY Orders Target", [CY Orders Target],
        "CY Orders Target Variance", [CY Orders Target Variance],
        "CY Orders Progress %", [CY Orders Progress %],
        "Total Revenue", [Total Revenue],
        "CY Revenue Target", [CY Revenue Target],
        "CY Revenue Progress %", [CY Revenue Progress %]
    )
    Measure = 
    SWITCH (
        [Selected Measure],
        "By Counts",
            COUNTROWS (
                FILTER (
                    MatrixColumns,
                    MatrixColumns[Measure Name]
                        IN {
                        "Total Orders",
                        "CY Orders Target",
                        "CY Orders Target Variance",
                        "CY Orders Progress %"
                    }
                )
            ),
        "By Revenue",
            COUNTROWS (
                FILTER (
                    MatrixColumns,
                    MatrixColumns[Measure Name]
                        IN { "Total Revenue", "CY Revenue Target", "CY Revenue Progress %" }
                )
            )
    )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.