Forum Discussion

venug's avatar
venug
Helper II
6 years ago
Solved

DAX - Create measure to count Store type

Hi Everyone,   Based on store type I need the count of unique outlets at month level ( this was done as it is a direct statement). However they want to implement having multiple months selection. W...
  • v-alq-msft's avatar
    6 years ago

    Hi, venug 

     

    Based on your description, you can create the Table 2 and Table 3 as follows.

    Table 2 =

    SUMMARIZE (

        'Table 1',

        'Table 1'[Store],

        "Store type",

        VAR j =

            CALCULATE (

                MAX ( 'Table 1'[Store type] ),

                FILTER ( 'Table 1', 'Table 1'[Month] = "Jan" )

            )

        VAR k =

            CALCULATE (

                MAX ( 'Table 1'[Store type] ),

                FILTER ( 'Table 1', 'Table 1'[Month] = "Feb" )

            )

        RETURN

            IF (

                j = "new"

                    && k = "retain",

                "Retain",

                IF (

                    j = "new"

                        && k = "laspsed",

                    "Lapsed",

                    IF (

                        j = "retain"

                            && k = "retain",

                        "Retain",

                        IF ( k = "" || ISBLANK ( k ), j, k )

                    )

                )

            )

    )

     

    Table 3 = SUMMARIZE(

        'Table 2',

        'Table 2'[Store type],

        "Count",

        COUNT('Table 2'[Store type])

                          

    )

     

    Result:

    Table 2:

    Table 3:

    Best Regards,

    Allan

     

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