Forum Discussion

TRPBI's avatar
TRPBI
New Member
4 years ago
Solved

DAX Query

Hello,
I need your help please.
i have a column i created with the dax, the values for example A, AB, ABC, BC, C, B, AC, i need to create a filter that shows me A, B, C
A : when the values are A, AB, ABC, AC
B : when the values are AB, ABC, BC, B
C : when the values are ABC, BC, C, AC
I created a DAX query
Team = IF (NameColumn IN {"A", "AB", "ABC", "AC"}, "A"
, IF (NameColumn IN {"AB", "ABC", "BC", "B"}, "B"
, if (NameColumn IN {"ABC", "BC", "C", "AC"}, "C", "Other")))
This DAX query did not work, it shows me these results :

For exemple :

when I click on A in the filter it shows me the sum of AB, A, ABC : 2+3+5

when I click on B in the filter it shows me the sum of  : BC,B : 4+2

when I click on B in the filter it shows me the sum of  : BC,B : 4+2

it does not show me the value C in the filter.

 

 

but what I'm looking for is to make a filter with the values A, B and C

Exemple:

when I click on A in the filter it shows me the sum of AB, A, ABC : 2+3+5

where i click on B in the filter it shows me the sum of AB,ABC,BC,B : 2+5+4+2

where i click on C in the filter it shows me the sum of ABC,BC : 5+4 

is it possible to do that ?

Thanks for your help

 

  • Hi TRPBI ,

    According to your description, here’s my solution.

    1.Create a table, there’s no relationship between the two tables.

     

    2.Create a measure.

    Result =

    SWITCH (

        SELECTEDVALUE ( 'Table (2)'[Type] ),

        "A",

            CALCULATE (

                SUM ( 'Table'[Value] ),

                FILTER ( 'Table', [Tag] IN { "AB", "A", "ABC" } )

            ),

        "B",

            CALCULATE (

                SUM ( 'Table'[Value] ),

                FILTER ( 'Table', [Tag] IN { "AB", "ABC", "BC", "B" } )

            ),

        "C",

            CALCULATE (

                SUM ( 'Table'[Value] ),

                FILTER ( 'Table', [Tag] IN { "ABC", "BC" } )

            )

    )

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    TRPBI Well of course not, all of your C's are in your A's and B's. So you have a disconnected table for A, B and C selection or ? I'm not exactly clear on this one.

  • Hi TRPBI ,

    According to your description, here’s my solution.

    1.Create a table, there’s no relationship between the two tables.

     

    2.Create a measure.

    Result =

    SWITCH (

        SELECTEDVALUE ( 'Table (2)'[Type] ),

        "A",

            CALCULATE (

                SUM ( 'Table'[Value] ),

                FILTER ( 'Table', [Tag] IN { "AB", "A", "ABC" } )

            ),

        "B",

            CALCULATE (

                SUM ( 'Table'[Value] ),

                FILTER ( 'Table', [Tag] IN { "AB", "ABC", "BC", "B" } )

            ),

        "C",

            CALCULATE (

                SUM ( 'Table'[Value] ),

                FILTER ( 'Table', [Tag] IN { "ABC", "BC" } )

            )

    )

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Kriekis's avatar
    Kriekis
    Frequent Visitor

    Hi,

    I see that measure [Result] can be more dynamic as well.

    So try the measure below:

     

    Result2 =
    VAR TagsInSegment =
    FILTER(
    ADDCOLUMNS(
    SUMMARIZE(
    ALLSELECTED('Table'),
    'Table'[Tag]
    ),
    "IsTagInSegments", NOT ISEMPTY (
    FILTER (
    'Table (2)',
    FIND('Table (2)'[Type],'Table'[Tag],,0) > 0
    )
    )
    ),
    [IsTagInSegments]
    )
    RETURN
    CALCULATE(
    SUM('Table'[Value]),
    KEEPFILTERS(TagsInSegment)
    )