Forum Discussion

BoBBie's avatar
BoBBie
Frequent Visitor
7 years ago
Solved

ytd multipe years

I have a database with all sales data from 2012 (inclusing a seperate date table). I want to display the sales orders amount of current year to date (data is updated / synct daily) including all prev...
  • BoBBie's avatar
    BoBBie
    7 years ago

    parry2kv-frfei-msft,

     

    solved by searching the community YTD untill today thanks to OwenAuger

     

     

     

    YTD Values till last orderdate = 
    VAR LOD = [Last Order Date]
    VAR TodayMonth =
        MONTH ( LOD )
    VAR TodayDay =
        DAY ( LOD )
    VAR YearDateFilter =
        GENERATE (
            VALUES ( 'date table'[year] );
            VAR TodayInCurrentYear =
                DATE ( 'date table'[year] ; TodayMonth; TodayDay )
            RETURN
                CALCULATETABLE (
                    DATESYTD ( 'date table'[Date] );
                    TREATAS ( { TodayInCurrentYear }; 'date table'[Date] )
                )
        )
    RETURN
        CALCULATE ( DISTINCTCOUNT(Blad1[orderno]); KEEPFILTERS ( YearDateFilter ) )

    and

     

     

    YTD-PY values till last order date = CALCULATE([YTD Values till last orderdate];SAMEPERIODLASTYEAR('date table'[Date]))