Forum Discussion
Last Week vs This Week Comparison
Not sure if this will solve your issue but you can get some perspective from this answer:
To achieve the desired output in Power BI, you can create a measure using DAX (Data Analysis Expressions). Below is an example measure that you can use:
OppHistoryLastWeekThisWeek =
VAR LastWeekStart = TODAY() - WEEKDAY(TODAY(), 2) - 6 - 7
VAR LastWeekEnd = TODAY() - WEEKDAY(TODAY(), 2) - 7
VAR ThisWeekStart = TODAY() - WEEKDAY(TODAY(), 2) + 1
VAR ThisWeekEnd = TODAY() - WEEKDAY(TODAY(), 2)
RETURN
SUMMARIZE (
OppHistory,
OppHistory[Stage OldValue],
"Last Week",
CALCULATE (
SUMX (
FILTER (
OppHistory,
OppHistory[Edit Date] >= LastWeekStart
&& OppHistory[Edit Date] <= LastWeekEnd
),
OppHistory[Amount]
)
),
"This Week",
CALCULATE (
SUMX (
FILTER (
OppHistory,
OppHistory[Edit Date] >= ThisWeekStart
&& OppHistory[Edit Date] <= ThisWeekEnd
),
OppHistory[Amount]
)
)
)
This measure calculates the sum of amounts for each stage for the last week and this week. It uses the SUMMARIZE function to create a table that includes the distinct values of the "Stage OldValue" field and calculates the sum of amounts for the specified date ranges.
Make sure to replace "OppHistory" with the actual name of your table if it's different. You can then use this measure in a table or matrix visualization in Power BI to display the desired output. The measure creates columns for "Last Week" and "This Week" amounts for each stage.
If this helped, Subscribe AnalyticPulse on YouTube for future updates:
https://www.youtube.com/@AnalyticPulse
https://instagram.com/analytic_pulse
https://analyticpulse.blogspot.com/
subscribe to Youtube channel For fun facts:
https://www.youtube.com/@CogniJourney