Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi Everyone,
i have seen that dax doesnt have a previous week function, can someone assist in writing a measure that shows previous week counts to compare to that current week count as shown in the tables below.
The first table is a representation of the actual data and the second table is the desired outcome.
If anyone can assist in writing such a measure I would greatly apreciate it,
Thank you
Data table
Expected outcome
Solved! Go to Solution.
Var _maxWeekNum = max(weeknum)
return
Calculate(
countrows(table),
filter(
all(table),
table[weeknum] = _maxWeekNum - 1
)
)
@tatenda24 , Please check the solution by @vapid128 , The solution work well within a year. Across year week need week rank column. Prefer a date table
new columns
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format
New measure examples
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))
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
Var _maxWeekNum = max(weeknum)
return
Calculate(
countrows(table),
filter(
all(table),
table[weeknum] = _maxWeekNum - 1
)
)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
42 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
39 | |
33 | |
18 | |
17 |