Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.
Hello everyone,
I have a periodic table of dates that I want to use as follows. I am using this on slicer. but I want to calculate the last 1 and 2 weeks as calendar week like in powerbi. how can I do that? Last 1 week date range for today I want: 27.11.2022-3.11.2022
VAR _datetable = DimTarih
VAR _today = TODAY()
VAR _year = YEAR(TODAY())
VAR _thisyearstart = DATE(_year,1,1)
VAR _year1 = YEAR(TODAY())-1
VAR _yearstart = DATE(_year1,1,1)
VAR _month = MONTH(TODAY())
VAR _thismonthstart = DATE(_year,_month,1)
VAR _thisyearstart1 = DATE(_year,12,31)
RETURN UNION(
ADDCOLUMNS(FILTER(_datetable,[TheDate]>_today-7 && [TheDate]<=_today),"Period","Last 1 week","Order",1),
ADDCOLUMNS(FILTER(_datetable,[TheDate]>_today-14 && [TheDate]<=_today),"Period","last 2 week","Order",2)
)
Solved! Go to Solution.
Hi, @sonya7
You need to subtract the value of WEEKDAY(_today) in your original formula.
t1 =
VAR _datetable = DimTarih
VAR _today =
TODAY ()
VAR _year =
YEAR ( TODAY () )
VAR _thisyearstart =
DATE ( _year, 1, 1 )
VAR _year1 =
YEAR ( TODAY () ) - 1
VAR _yearstart =
DATE ( _year1, 1, 1 )
VAR _month =
MONTH ( TODAY () )
VAR _thismonthstart =
DATE ( _year, _month, 1 )
VAR _thisyearstart1 =
DATE ( _year, 12, 31 )
RETURN
UNION (
ADDCOLUMNS (
FILTER (
_datetable,
[TheDate]
> _today - 7
- WEEKDAY ( _today )
&& [TheDate]
<= _today - WEEKDAY ( _today )
),
"Period", "Last 1 week",
"Order", 1
),
ADDCOLUMNS (
FILTER (
_datetable,
[TheDate]
> _today - 14
- WEEKDAY ( _today )
&& [TheDate]
<= _today - WEEKDAY ( _today ) - 7
),
"Period", "last 2 week",
"Order", 2
)
)
Result:
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @sonya7
You need to subtract the value of WEEKDAY(_today) in your original formula.
t1 =
VAR _datetable = DimTarih
VAR _today =
TODAY ()
VAR _year =
YEAR ( TODAY () )
VAR _thisyearstart =
DATE ( _year, 1, 1 )
VAR _year1 =
YEAR ( TODAY () ) - 1
VAR _yearstart =
DATE ( _year1, 1, 1 )
VAR _month =
MONTH ( TODAY () )
VAR _thismonthstart =
DATE ( _year, _month, 1 )
VAR _thisyearstart1 =
DATE ( _year, 12, 31 )
RETURN
UNION (
ADDCOLUMNS (
FILTER (
_datetable,
[TheDate]
> _today - 7
- WEEKDAY ( _today )
&& [TheDate]
<= _today - WEEKDAY ( _today )
),
"Period", "Last 1 week",
"Order", 1
),
ADDCOLUMNS (
FILTER (
_datetable,
[TheDate]
> _today - 14
- WEEKDAY ( _today )
&& [TheDate]
<= _today - WEEKDAY ( _today ) - 7
),
"Period", "last 2 week",
"Order", 2
)
)
Result:
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You are legend! thank you
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
72 | |
67 | |
65 | |
42 | |
42 |
User | Count |
---|---|
46 | |
38 | |
28 | |
26 | |
26 |