Forum Discussion

RobertSlattery's avatar
RobertSlattery
Responsive Resident
8 years ago

Allselected function not removing row context for date hierarchy

Why does AllSelected not deliver the same behaviour in the two cases below? 

startDate = CALCULATE(
    FIRSTDATE('Dim Date'[DateRaw].[Date]),
    ALLSELECTED('Dim Date'[DateRaw].[Date])
)

9 Replies

    • RobertSlattery's avatar
      RobertSlattery
      Responsive Resident

      Hi Phil_Seamark I don't understand your answer.  In my experience, AllSelected removes the row context and preserves the visual state (as determined by the visual).  This is exactly what it does for the right-hand side version, where I selected the date rather than the date hierarchy.  In this case it removes the row context and I am left with the page context as defined by the slicer.  How is this different to the left hand version?

       

      ALL and ALLEXCEPT don't help me because I need to preserve the page context.

      • Phil_Seamark's avatar
        Phil_Seamark
        Microsoft Employee

        You are quite correct and my answer was poor.  In fact it woke me up to come and fix.  The ALLSELECTED function will only remove filters from tables or columns internal to your query (visual)

         

        The syntax you are using only removes the filter column from a specific column in the hidden date table and nothing else.  

         

        You are using ALLSELECTED to clear filters from the folloing column in your measure

        Dim Date'[DateRaw].[Date]

         

        Whereas you are ACTUALLY using the following column in your query

         

         

        'Dim Date'[DateRaw].[Day]

         

        There is a very subtle difference and means your ALLSELECTED function not removing the filter off the .[DAY] and this filter is being propogated back to the 'Dim Date' table and restricting the rows visible to the FIRSTDATE function.

         

        If you change your measure to the following, your measure will now return the same value

         

        startDate = CALCULATE(
            FIRSTDATE('Dim Date'[DateRaw].[Date]),
            ALLSELECTED('Dim Date'[DateRaw].[Day])
        )