Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Let's say I have the following fields in a table:
If a person selects a week and a year, I want to dynamically calculate the Six Week Average of Quantity Shipped. Keeping in mind that a person could choose some combination of Week and Year that would overlap to another year, perhaps the best approach would be something like this:
Now...how to put that in an expression so it can be done dynamically?
I started by trying this equation just to get the WeekStart of the ShipDate, but it returns records for all years and weeks, even though I specified variable values of '05' for the Week, and '2025' for the year:
=WeekStart({<Week={'$(vWeek)'},ShipYear={'$(vYear)'}>}ShipDate)
Any ideas or suggestions would be greatly appreciated!
You need only a running and sorted week-counter over all data - within the master-calendar which is simply to create, for example with measurements like:
and then:
sum({< WeekFlag = {">=$(max(WeekFlag)-6)<=$(max(WeekFlag))"}>} Value)
@mikegrattan Try below expression:
WeekStart({<Week={">=$(vWeek)-6<=$(vWeek)'},ShipYear={'$(vYear)'}>}ShipDate)
So when you select any week I will automatcally show your measure for that week range that is current week and 6 week s back
You need only a running and sorted week-counter over all data - within the master-calendar which is simply to create, for example with measurements like:
and then:
sum({< WeekFlag = {">=$(max(WeekFlag)-6)<=$(max(WeekFlag))"}>} Value)
Hi Marcus. This sounds promising...could you provide more details? I have the following Master Calendar in the app:
It might be done in such ways:
Marcus,
I appreciate the additional information, but I don't think I understand where this additional script would go. You mentioned an example earlier with a "WeekFlag" and I don't see that being created anywhere. Can you explain further please?
Thank you.
Flag 1 - 3 are (just different) ways to create the WeekFlag by skipping the resident-part and creating the period-information within n preceding-parts (it's just an example and not a fully calendar).
Meant was to create the calendar within an own and independent application which may create hundreds of different period-information and storing them in n qvd's. It's not necessary to create these information redundant in n application else everything needed could be simply picked from the qvd's.
Bhushan,
Thanks for your suggestion. I did try it, but I got an error in set modifier ad hoc element list. Also, I believe that your approach would not work when the week is between 1 and 6, since it would result in a 0 or a negative number.
Hi Marcus,
This post came the closest to my eventual solution, so I'll accept it.
I ended up doing the following:
(Num(Sum({<ShipDate_DayOfWeek={'Thu'},FloorShipdate={">=$(vStartSixWk)<=$(vEndSixWk)"}>}$(vMeasure))/6,'#,##0'))