+ Reply to Thread
Results 1 to 9 of 9

7 day rolling total using DATEADD help as to why it doesn't work on the formula

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    7 day rolling total using DATEADD help as to why it doesn't work on the formula

    Hello,
    I have a question as to how dateadd works, I've done 7 day rolling totals just using minus 7 and DATESINPERIOD

    Please Login or Register  to view this content.
    and the same result ;

    Please Login or Register  to view this content.
    But I've tried to use Dateadd , I've put it into dax studio and for each 'row' using addcolumns it returned a date seven day prior to the current row date, but if I try the following I just get a a running total , I've tried change the 'Calendare [date] for the variable mdate but it didn't seem to make a difference, I've attached the work book any help as to why it doesn't work would be helpful.




    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    If you think about it logically:

    'Calendar'[Date] > DATEADD ( 'Calendar'[Date], -7, DAY )

    will be true for every date, since any date is greater than a date 7 days prior to it...
    Rory

  3. #3
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    Yes, I can see that, but it does work in excel, and I know things work differently,


    Please Login or Register  to view this content.

    also the same could be said where I've used the MAXDATE() variable, mdate - 7, but that seems to work,

    I did try using MAX , VALUES and a few others to try and use the var with dateadd ,but no good.

    Richard.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    Actually, the nearest Excel equivalent would be:

    SUMIF($E$6:E6,">"&$E$6:E6-7,$F$6:$F$25)

    It seems to me that you should be using:

    DATEADD ( MAX('Calendar'[Date]), -7, DAY )

    just as you did with the other formulas.

  5. #5
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    First Sorry not getting back to you before now,

    Re the excel formula I've always just use a single unlocked cell for the criteria

    Please Login or Register  to view this content.
    , seem to work.
    As to DATEADD, i have been trying to use it , but just get a cumulative total,

    Please Login or Register  to view this content.
    , I have tried putting the variable last clause ;
    Please Login or Register  to view this content.
    But doesn't seem to make a difference?

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    You missed my point. Using Table3[Date] is not the equivalent of a single cell in Excel, it's the equivalent of a table column.

    You seem to have ignored my suggestion about MAX.

  7. #7
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    I had tried this before, and Values, but have not got it accepted, when I close on MAX and add a comma to move to number of intervals,
    the MAX ( ) part is underlined red. It's really annoying as I cant see why it doesn't work.

    Richard

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    The way you are trying to use it is a little weird to be honest. You'd have to reverse the logic for this:

    =VAR mdate = MAX('Calendar'[Date])
    VAR asner = CALCULATE([Tsales],FILTER(ALLSELECTED('Calendar'[Date]),'Calendar'[Date] <= mdate && mdate < DATEADD('Calendar'[Date] ,7,DAY) ) )
    RETURN
    IF([Tsales],asner)

  9. #9
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: 7 day rolling total using DATEADD help as to why it doesn't work on the formula

    Thanks,
    I'll mark this up, yes, I know a bit weird, but I just wanted to see if it could be done, I find with a lot of DAX functions, just when you think you know how they work they give an unexpected result.
    My next question is probably going to be AVERAGEX.
    Thanks for the help,

    RD

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Rolling 12 Week Total Or Average Formula
    By exceln00b0151 in forum Excel Formulas & Functions
    Replies: 24
    Last Post: 01-13-2021, 12:07 PM
  2. [SOLVED] adding up formula that doesn't exceed a set total
    By markxl111 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-27-2020, 08:55 AM
  3. [SOLVED] Sum Formula for Rolling 12 month Data total
    By kvasir01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-20-2018, 09:49 AM
  4. [SOLVED] Fix Formula to total a row by month for a rolling 12 months
    By heresteve2 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 10-04-2014, 03:52 PM
  5. formula in Excel to calculate rolling daily average of sales total by date
    By Geekgurl in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-17-2014, 05:30 PM
  6. Rolling total Formula Help Required
    By Killer17 in forum Excel General
    Replies: 4
    Last Post: 08-17-2009, 05:04 PM
  7. Replies: 4
    Last Post: 12-04-2008, 10:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1