Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Create a single filter to filter across two columns

Hi,   I'm terribly sorry if this has been asked multiple times however I can't seem to find a quick solution to this query.   I have a dataset that has multiple columns, two of these columns are ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    HI Anonymous,

    #1, Unpivot columns show be a better choice to handle multiple value field interactions, but it will expand your table records so it should not suitable to work with tables that include larger amount of records.

    For this scenario, you can consider extracting the category field and value fields to a new table that only includes the key fields, then do unpivot on it. (it should better than direct expand raw tables records)

    #2. According to your description, it seems like you are trying to create a dynamic field that based on filter selection. For this requirement, you need to create a parameter table that stored the value field names, then you can use it on the switch function to show different table field values based on current selections.

    Measure =
    // parameter table stored A,B,C,D types of field name
    VAR selected =
        SELECTEDVALUE ( ParaTable[Field Name] )
    RETURN
        SWITCH (
            selected,
            "A", SUM ( Table[Field A] ),
            "B", SUM ( Table[Field B] ),
            "C", SUM ( Table[Field C] ),
            "D", SUM ( Table[Field D] ),
            //default and exception case
            SUM ( Table[Field A] )
        )

    BTW, current power bi does not support creating a dynamic calculated column/table based on filter selections. Please use the measure formula instead.
    Regards,

    Xiaoxin Sheng