cancel
Showing results for
Did you mean:
Regular Visitor

## To create a accumulated/YTD and LYTD for weekly basis.

Hi Everyone,

Can someone help me to create a accumulated/YTD for weekly basis. Below is the measure I am created, but not given as excepted.

For example, if I am selecting 202147 as a week, its should give data between 202136 to 202047 (My fisical year starts from Sep thats why we considering week 36 as 1st week).
I need to calculate LYTD which would consider 202036 to 202047.

accTest =
Var _currentweek = SELECTEDVALUE('Date'[Week])
Var _previousWeek = _currentweek-100
RETURN
TOTALYTD (
SUM ( FACT_Table[Value EUR] ),
FILTER('Date','Date'[Week] = _previousWeek),
ALL('Date'),
"08/31"
)

Super User

@nareshk , Create a date/ week table with week, year, year week and year week rank

New columns in date /week tables

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
Week = WEEKNUM([Date],2)
year Week = if('Date'[Week Number]<10,'Date'[Year]*10 & 'Date'[Week Number],'Date'[Year]&'Date'[Week Number])
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

measures
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
or
Last year Week= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -53)))
or
This year week= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] = Max('Date'[Week]) ))
Last year same week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Week] = Max('Date'[Week])))

New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Announcements