Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Good morning,
I'm trying to get all sales for the last eight weeks.
I manged to get the 8 week but would like to exclude the current week
Measure 3 =
CALCULATE([QTY_Sales],
FILTER(SalesData,
DATEDIFF(SalesData[DDate],TODAY(),WEEK) < 8
)
)Any ideas?
Thanks in advance.
Solved! Go to Solution.
Hi @brinky ,
According to the description, you may try this:
Measure =
CALCULATE (
[QTY_Sales],
FILTER (
'SalesData',
DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) < 8
&& DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) >= 1
)
)
If it does not make sense, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @brinky ,
According to the description, you may try this:
Measure =
CALCULATE (
[QTY_Sales],
FILTER (
'SalesData',
DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) < 8
&& DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) >= 1
)
)
If it does not make sense, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous
Thanks works as required.
Hey @brinky ,
based on my answer in this thread: Solved: Re: Week commencing in DAX - Microsoft Power BI Community
You can create something like this:
some weeks in the past =
var __today = TODAY()
var startOfWeeek = __today - WEEKDAY( __today , 2 ) + 1 //assuming the week starts with Monday
var endOfWeek = __today + 7 - WEEKDAY( __today , 2 )
var numberOfPreviousWeeks = 1
var startOfPrevWeeeks = startOfWeeek - 7 * numberOfPreviousWeeks
var endOfPrevWeek = endOfWeek - 7
return
CALCULATE(
[Actual Sales]
, DATESBETWEEN( 'DimDate'[Datekey] , startOfPrevWeeeks , endOfPrevWeek )
)
Hopefully, this provides something to tackle your challenge.
Regards,
Tom
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |