Forum Discussion

claytonduvall's avatar
claytonduvall
New Member
7 years ago

DATESYTD or TOTALYTD excluding filtered dates

Is there a way to use the DATESYTD or TOTALYTD DAX expression and allow it to exclude the dates that have been filtered by the user?     I tried both of these expressions, to display a YTD total for a KPISum measure.

 

YTD-KPISum:= CALCULATE (
'Daily KPI'[KPISum],
DATESYTD ( 'Date'[DayDate] )
)

 

YTD-KPISum:= TOTALYTD('Daily KPI'[KPISum],'Date'[DayDate])

 

It works fine when all of the dates are included and even with any other filters applied.  However, when I add any filter on the dates, (ex. Business Day only), it doesn't exclude those dates from the YTD totals.

 

See the example below.  Notice when I add a Business Day filter, the YTD-KPISum on 1/23/17 is 2 over.  In this case it is not filtering out the 2 on 1/22/17.  Is there a way I can get the YTD Sum to not include the dates that have been filtered?

 

3 Replies

    • claytonduvall's avatar
      claytonduvall
      New Member

      Thanks for the quick reply, Greg.    I don't quite follow your solution, here though.  In my case I do have a date field and it has the proper relationships set up.   The YTD function works fine in most cases.  It is just when the user wants to filter out certain dates like weekends where I can't get the YTD functions to work.  I can't quite figure out how to get these date expressions for YTD to exclude dates that are filtered out.   Any suggestions?

      • v-danhe-msft's avatar
        v-danhe-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi claytonduvall ,

        Could you please offer a sample file to have a test if possible?

         

        Regards,

        Daniel He