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.
Hello,
I am working on a project where I need to display historical data on a weekly basis (i.e. one week ago, two weeks ago, etc). The relative date slicer will not work as far as I understand because I do not want to see the data combined but rather separated. The best way I could think to do this would be to create a continuous week counter in Power BI that counts each week year over year instead of the default of 1-53 for each year, then starting back at 1 on the first week of January. I have attached a screen shot of my data table showing how when the new year begins the week counter restarts at one. Is there a formula that I can use so that the week count is continuous (instead of starting at 1 at the beginning of a new year the week count goes to 54). I have looked through various questions on the forums but have been unable to find an answer. Thank you!!!
Try this solution.
1. Create calculated table:
WeeksByYear =
SUMMARIZECOLUMNS (
DimDate[Year],
DimDate,
"Weeks In Year", CALCULATE ( MAX ( DimDate[Week Num of Year] ) )
)
2. Create calculated column in DimDate table:
Week Number Since Inception =
VAR vCurrentYear = DimDate[Year]
VAR vTable =
FILTER ( WeeksByYear, WeeksByYear[Year] < vCurrentYear )
VAR vTotalWeeksInPriorYears =
SUMX ( vTable, WeeksByYear[Weeks In Year] )
VAR vResult =
IF (
ISBLANK ( vTotalWeeksInPriorYears ),
DimDate[Week Num of Year],
vTotalWeeksInPriorYears + DimDate[Week Num of Year]
)
RETURN
vResult
Proud to be a Super User!
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 |
---|---|
110 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |