Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Year and Month Current Selections

ShowSlicerContents = 

IF (

    ISFILTERED ( AXA_Date[Date].[Year]) & ISFILTERED(AXA_Date[Month] ),

    "Year:" & UNICHAR ( 10 )

        & CONCATENATEX ( DISTINCT (  AXA_Date[Date].[Year]),  AXA_Date[Date].[Year], ", " )

     "Month:" & UNICHAR ( 10 )                                                                                         & CONCATENATEX ( DISTINCT (  AXA_Date[Date].[Month]),  AXA_Date[Date].[Month], ", " ),

          "No filter applied"

)


I am trying to create a current selections box.

I can bring Year on its own and Month on its own but trying to bring them out together in a Card.

Anyone see my measure  issue above?

7 Replies

  • Mariusz's avatar
    Mariusz
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous,

    Please see the below and do let me know if its what you need.

    Year Month Selected Slicer Values = 
    VAR y = ISFILTERED('Calendar'[Year])
    VAR m = ISFILTERED('Calendar'[Month])
    RETURN 
    SWITCH(
        TRUE(),
        y && m, CONCATENATEX(
            SELECTCOLUMNS(
                SUMMARIZE(
                    'Calendar',
                    'Calendar'[Year],
                    'Calendar'[Month]
                ),
                "str", 'Calendar'[Year] & "-" & 'Calendar'[Month]
            ),
            [str], "; "
        ),
        y, CONCATENATEX(
            VALUES('Calendar'[Year]),
            'Calendar'[Year], "; "
        ),
        m, CONCATENATEX(
            VALUES('Calendar'[Month]),
            'Calendar'[Month], "; "
        ),
        "All Selected"
    )

    If you have concatinated Year month field please replace the Concat in the code.

    Hope this helps
    Mariusz

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you. It now works but the only thing is when nothing is selected, i get all years back

       

      2017 2018 2019

       

      when it should be blank

      • Mariusz's avatar
        Mariusz
        Icon for Community Champion rankCommunity Champion

        Hi Anonymous 

        Can you send your code?

         

        Thanks

        Mariusz