Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi BI Community Team,
I have table of sales order, customer & supplier and looking for weekly sales comparion between current & last month. After applied the measure, grand total of last week (last month) doesn't show as the screenshot below.
Any suggestion & advise of this issue?
Thanks and Regards,
Solved! Go to Solution.
looking for weekly sales comparion between current & last month
weeks and months are incompatible.
Best you can do is date math like so
Hi All,
Thank you for your helpful feedback and advise.
Best Regards,
Hi @ADSL
Thank you very much rajendraongole1 and lbendlin for your prompt reply.
I made some modifications to your code, as follows:
Last Week Sales (PM) =
VAR _week = SELECTEDVALUE('Calendar'[Week of Month])
VAR _month = SELECTEDVALUE('Calendar'[Date].[MonthNo])
VAR _year = SELECTEDVALUE('Calendar'[Date].[Year])
VAR _isTotal = ISINSCOPE('Calendar'[Week of Month]) = FALSE()
RETURN
IF(
_isTotal,
CALCULATE(
SUM('Sales Order'[Amt]),
FILTER(
ALL('Calendar'),
YEAR('Calendar'[Date]) = _year
&&
MONTH('Calendar'[Date]) = _month-1
)
),
CALCULATE(
SUM('Sales Order'[Amt]),
FILTER(
ALL('Calendar'),
YEAR('Calendar'[Date]) = _year
&&
'Calendar'[Week of Month] = _week
&&
MONTH('Calendar'[Date]) = _month-1
)
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ADSL - you can try the below suggested solution from @lbendlin
adding another workaround, Your measure for "Last Week" likely calculates values per week, but at the total level, it might not aggregate correctly.
LastWeekSales =
CALCULATE(
SUM(Sales[SalesAmount]),
DATEADD(Sales[Date], -7, DAY)
)
To ensure correct totals, use ISINSCOPE to distinguish between row-level and total-level calculations.
LastWeekSales =
IF(
ISINSCOPE(Sales[Customer]),
CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -7, DAY)),
SUMX(
VALUES(Sales[Week]),
CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -7, DAY))
)
)
There should be a Date table marked as a date table in Power BI.Relationships between your sales table and the date table should be established correctly.
Hope this works . try both solutions . Thank you.
Proud to be a Super User! | |
looking for weekly sales comparion between current & last month
weeks and months are incompatible.
Best you can do is date math like so
User | Count |
---|---|
84 | |
78 | |
71 | |
48 | |
42 |
User | Count |
---|---|
111 | |
56 | |
50 | |
41 | |
40 |