Forum Discussion

YunJ's avatar
YunJ
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

Wrong result when putting different date.

Hi,

I wrote a measure like following:

When I put "Start Date" in the table, the result is correct. But for the bottom two tables, which I put "YearMonth" and "YearWeek" in the table, the result is not correct. Any solution to fix this?

 

Thanks a lot for your help!

  • Hi YunJ ,

     

    To my understanding, try to create your measure like so:

    8 (2) =
    CALCULATE (
        SUM ( timetest[Sales] ),
        FILTER (
            ALLSELECTED ( timetest ),
            timetest[Land Date] IN VALUES ( timetest[Start Date] )
                && timetest[Presale_or not] = "Y"
        )
    )
    

     

     

    Best Regards,

    Icey

     

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

8 Replies

  • YunJ why you are using allexcept function? Can you define what you are trying to achieve?

    • YunJ's avatar
      YunJ
      Icon for Post Prodigy rankPost Prodigy

      Hi parry2k 

       

      I wrote allexcept(table[category]) to make my Category slicer can work. When I only used all(table), the Category slicer does not work.

       

      Thanks

      Yun

  • Icey's avatar
    Icey
    Icon for Community Support rankCommunity Support

    Hi YunJ ,

     

    To my understanding, try to create your measure like so:

    8 (2) =
    CALCULATE (
        SUM ( timetest[Sales] ),
        FILTER (
            ALLSELECTED ( timetest ),
            timetest[Land Date] IN VALUES ( timetest[Start Date] )
                && timetest[Presale_or not] = "Y"
        )
    )
    

     

     

    Best Regards,

    Icey

     

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

    • YunJ's avatar
      YunJ
      Icon for Post Prodigy rankPost Prodigy

      Hi Icey 

      Thanks for your great solution.

      May I ask why you use ALLSELECTED function? and why you use 

      timetest[Land Date] IN VALUES ( timetest[Start Date] )

      rather than  

      timetest[Land Date] = SELECTEDVALUE( timetest[Start Date] )

       

      Thanks for your time and patience!

      Yun 

      • Icey's avatar
        Icey
        Icon for Community Support rankCommunity Support

        Hi YunJ ,

         

        1. I use ALLSELECTED() to Remove context filters from columns and rows in the current query, while retaining all other context filters or explicit filters. For details, please refer to this blog: The definitive guide to ALLSELECTED.

         

        2. If use SELECTEDVALUE(), the expression only works when one record "selected". But use VALUES(), it will return a list of records.

         

         

        Best Regards,

        Icey

         

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