Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
m_baroja
Partner - Contributor III
Partner - Contributor III

Complex set analysis using ranges and max dates for each dimension value

Hi all!

This is being a very challenging problem what I am facing, hope you can help me.

I'm attaching an example Excel file and a .qvw file with loaded data. There, you can see we have sold article amounts by date and article.

Date1ArticleAmount
01/01/2020Art1100
02/01/2020Art1200
06/01/2020Art1300
07/01/2020Art1400
02/01/2020Art2500
03/01/2020Art2600
09/01/2020Art2700
10/01/2020Art2800

This is the problem: the end user has the possibility to use a selector and write a offset value for the date -in this example, for simplifying purposes, I'm adding to year's first day so many days as vDayCounter variable says. Then, having this calculated date as reference, I need to get the amount corresponding to the maximum date for each article, being this date lower than the calculated date.

Using this table as example, let's say you set vDayCounter=4. So, our calculated day will be 05/01/2020. Then this means we want this amounts:

Date1ArticleAmount
02/01/2020Art1200
03/01/2020Art2600

 

I tried AGGR to obtain dates at article level, combining with Max() function, but it didn't work anyway.

Thanks in advance for your interest!

Miguel

 

 

Labels (1)
1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hi 

this should solve your question 

FirstSortedValue({<Date1={"<=$(=date(Max(Date1)+vDayCounter))"}>}  aggr( sum({<Date1={"<=$(=date(Max(Date1)+vDayCounter))"}>}Amount),Date1,Article) ,-Date1)

also attach is your demo model  

View solution in original post

2 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

this should solve your question 

FirstSortedValue({<Date1={"<=$(=date(Max(Date1)+vDayCounter))"}>}  aggr( sum({<Date1={"<=$(=date(Max(Date1)+vDayCounter))"}>}Amount),Date1,Article) ,-Date1)

also attach is your demo model  

m_baroja
Partner - Contributor III
Partner - Contributor III
Author

Very nice. It works!

Thank you!