Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi All,
Provided my original dataset and Prev Week value
The problem is when we are going from 2019 to 2020 i am facing issue. When more than 1 year of data is involved then i am not getting 2020-1 i.e., first week of 2020 value for Previous week.
Provided the measure which i am using for 2nd table shohwn in above screenshot
If you have only weeks in your dimensions. Then refer to this solution
In case you have dates try
This week sales =
var _date = date(year(today()),month(today()),day(today()))
var _Week_ED = _date + (-1*WEEKDAY(_date)+1)
var _Week_SD= _date +(7-1*WEEKDAY(_date))
Return
CALCULATE(sum(Sales[Sales Amount]),all('Date'),Sales[Sales Date]>=_Week_SD && Sales[Sales Date]<=_Week_ED)
Last week sales =
var _date = date(year(today()),month(today()),day(today()))
var _Week_ED = _date +( (-1*WEEKDAY(_date)+1)-7)
var _Week_SD= _date +((7-1*WEEKDAY(_date))-7)
Return
CALCULATE(sum(Sales[Sales Amount]),all('Date'),Sales[Sales Date]>=_Week_SD && Sales[Sales Date]<=_Week_ED)
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
Hi @amitchandak
I couldn't able to open the pbix file which was shared in the below path.
It is showing access denied for me (Some issue from my side to the access)
Thanks
Try this link
Unfortunately still couldn't able to open that link.
I hope we need to create a max year variable and whenever weeknum<2 then Max of year - 1 like something.
if you have week dimension table and it has weekno is like YYYYWW
Then
RankedWeek = RANKX(Week,Week[WeekNo],,ASC)
Sales this Weeks = CALCULATE(SUM('Table'[Sales]), FILTER(ALL(Week), Week[RankedWeek] = MAX(Week[RankedWeek]) ))
Sales Last Weeks = CALCULATE(SUM('Table'[Sales]), FILTER(ALL(Week), Week[RankedWeek] = (MAX(Week[RankedWeek])-1) ))
Hi @amitchandak ,
The below code is working fine for me but i dont want to give 52 as static. Can we make this as dynamic?
Try like . Do necessary modification
Prev Week =
var _date = date([C_Year]-1,12,31)
var _maxPweek = weekno(_date)
VAR _maxWeek1 = MAXX('Calculated Table','Calculated Table'[C_WeekNum])
VAR _maxWeek = if([_maxWeek1]=1 ,_maxPweek, _maxWeek1-1)
var _cYear =MAXX('Calculated Table','Calculated Table'[C_Year])
Var _maxYear = if([_maxWeek1]=1,_cYear-1,_cYear)
return
CALCULATE(
SUM('Calculated Table'[C_Sales]),
'Calculated Table'[C_Year] = _maxYear,'Calculated Table'[C_WeekNum] = _maxWeek,
all( 'Calculated Table')
)
User | Count |
---|---|
85 | |
74 | |
71 | |
68 | |
56 |
User | Count |
---|---|
96 | |
94 | |
92 | |
78 | |
71 |