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.
how to have current week and previse week
Solved! Go to Solution.
Here's a really messy way of doing it that I'm sure someone will improve on:
/*calculated table*/
Current and Previous Week Hours =
var _currentDate = Max('Date'[Date])
var _currentWkStart = DATEADD(_currentDate, -6, Day)
var _previousWkStart = DATEADD(_currentWkStart, -14, Day)
Return Summarize("CurrentWeekHours", sumx(Filter(AllSelected(Overall), [Date]>=_currentWkStart && [Date] <=_currentDate), [Hours])
, "PreviousWeekHours", sumx(Filter(AllSelected(Overall), [Date]<_currentWkStart && [Date] >=_previousWkStart), [Hours]))
Alternatively you could use the variables to create a flag (calculated column) in your date table to identify current and previous weeks 😆
/*Calcuated Current Week Flag */ Return if(AND([Date] >=_currentWkStart, [Date] <=_currentDate), "Y", "N")
/*Calcuated Previous Week Flag */ Return if(AND([Date] >=_currentWkStart, [Date] <=_currentDate), "Y", "N")
Here's a really messy way of doing it that I'm sure someone will improve on:
/*calculated table*/
Current and Previous Week Hours =
var _currentDate = Max('Date'[Date])
var _currentWkStart = DATEADD(_currentDate, -6, Day)
var _previousWkStart = DATEADD(_currentWkStart, -14, Day)
Return Summarize("CurrentWeekHours", sumx(Filter(AllSelected(Overall), [Date]>=_currentWkStart && [Date] <=_currentDate), [Hours])
, "PreviousWeekHours", sumx(Filter(AllSelected(Overall), [Date]<_currentWkStart && [Date] >=_previousWkStart), [Hours]))
Alternatively you could use the variables to create a flag (calculated column) in your date table to identify current and previous weeks 😆
/*Calcuated Current Week Flag */ Return if(AND([Date] >=_currentWkStart, [Date] <=_currentDate), "Y", "N")
/*Calcuated Previous Week Flag */ Return if(AND([Date] >=_currentWkStart, [Date] <=_currentDate), "Y", "N")
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.