Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

date(floor not working

Hi experts

We have to calculate the day difference between two date fields: 

sum(date(floor([Code Date] - [Posting Day]))+1 ), but the result with "sum" is incorrect.

 

TomBond77_0-1676533850034.png

With this formula date(floor([Code Date] - [Posting Day]))+1  the result is correct:

TomBond77_1-1676534132845.png

 

 

But we need the "sum" for further ongoing calculations, without having the dates in the drill down. Any ideas?

 

Labels (1)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

When the expression is evaluated, the engine loops over all combinations of [Code Date] and [Posting Day]. You seem to have two combinations, both evaluated to 378, so the sum is 756. Is this an error in the data model?

If this is the data model you want, you will need another expression, e.g.
Sum(Aggr(Avg(date(floor([Code Date] - [Posting Day]))+1),X))

This will loop over X, calculate the Avg, and then sum the result of each iteration. The question is only: What is X? It could be IssueNo or some other primary key.

View solution in original post

1 Reply
hic
Former Employee
Former Employee

When the expression is evaluated, the engine loops over all combinations of [Code Date] and [Posting Day]. You seem to have two combinations, both evaluated to 378, so the sum is 756. Is this an error in the data model?

If this is the data model you want, you will need another expression, e.g.
Sum(Aggr(Avg(date(floor([Code Date] - [Posting Day]))+1),X))

This will loop over X, calculate the Avg, and then sum the result of each iteration. The question is only: What is X? It could be IssueNo or some other primary key.