Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi all,
I would like to sum the quantity in the SKU level for last 30 days from today(), for each sales channel.
The data table (example) looks like that:
I tried with this measure, but still, this is not done. Can anyone help me out with how to get the right result?
I tried to see this link: Calculate Sales Past 30 Days, but it is not fulfilling the requirements.
Regards,
Ahsan
Solved! Go to Solution.
@Anonymous if you dont have calender table with below code: based on requirement-
calender("01/01/2020","01/01/2025")
or else you can try below code:-
QuantityLast30Day =
VAR max_date =
MAX ( flatFileOrders[updateat] )
VAR last_30days =
MAX ( flatFileOrders[updateat] ) - 30
RETURN
CALCULATE (
SUM ( flatFileOrders[quantity] ),
FILTER (
flatFileOrders,
flatFileOrders[updateat] <= max_date
&& flatFileOrders[updateat] >= last_30days
)
)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi @Anonymous ,
Use your date table inside dateperiod function.
QuantityLast30Day =
CALCULATE (
SUM ( flatFileOrders[quantity]),
DATESINPERIOD (Datetable[date], MAX(Datetable[date]), -30, DAY )
)
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi @Samarth_18 ,
i don't have a separate date table in my data model.
Do, i need to create a date table? if yes, can you please tell me how to do it?
I'm not very experienced in Power BI.
Thanks.
@Anonymous if you dont have calender table with below code: based on requirement-
calender("01/01/2020","01/01/2025")
or else you can try below code:-
QuantityLast30Day =
VAR max_date =
MAX ( flatFileOrders[updateat] )
VAR last_30days =
MAX ( flatFileOrders[updateat] ) - 30
RETURN
CALCULATE (
SUM ( flatFileOrders[quantity] ),
FILTER (
flatFileOrders,
flatFileOrders[updateat] <= max_date
&& flatFileOrders[updateat] >= last_30days
)
)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
User | Count |
---|---|
77 | |
77 | |
68 | |
67 | |
49 |
User | Count |
---|---|
108 | |
105 | |
93 | |
83 | |
64 |