Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Min date doesn't work with Sum

Hello All,

I am trying to calculate an indicator using minimum date. So i set a
variable called 'vPeriodStart' like this

vPeriodStart= min(uDAY) and it gives the earliest date back for a selected fiscal period. Now if i want to use this variable like this

sum(if(Opening > $(vPeriodStart)
or ClosingDate
< $(vPeriodStart) ,0,1)) it

does not work. I also tried

sum(if(Opening >min(uDAY) or ClosingDate < min(uDAY),0,1)) but same result it gives me no value back.

i also tried to format date in every
possible way with Date and Date# it does not work. I am confused why i am
unable to use Min(Date) function in sum formula.

now i if set the value of variable

vPeriodStart= today()

vPeriodStart='09.09.2013'

it works

Now i need to make it works with vPeriodStart= min(uDAY) I tried every possible way but it not working. I am wondering if anybody can help me this

Thnaks

1 Solution

Accepted Solutions
swuehl
MVP
MVP

As said, you need to use a leading equal sign (which was missing in your app) in the variable definition and you need to create a number:

=num(min(uDAY))

in variable overview. Result of you expression is then 189.

View solution in original post

10 Replies
swuehl
MVP
MVP

Have you defined your variable in variable overview with a leading equal sign or without? Try with an equal sign

=min(uDAY)

and check the result in a text box:

=vPeriodStart

then, if you get an expected result, try

sum(if(Opening > vPeriodStart
or ClosingDate
< vPeriodStart ,0,1))

Not applicable
Author

Hi,

I tried the = sign it does not work. I already tested the output of variable in a text box it works fine and it gives the minimum date back.

Not applicable
Author

Hi

I seem to think that this is with regards to the format of the returned value.

Put an Input box and list box on a sheet and compare the Opening  and $(vPeriodStart) values to each other.

If this doenst work, do you mind send a Qvw model? Might give a better picture of whats going wrong?

swuehl
MVP
MVP

I am assuming that your Opening and ClosingDate are QV dates, with a numeric representation, right?

And your variable is also a number, right?

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Isn't this a case of nested aggregation? It certainly works when you set variable vPeriodStart in your load script. But then you loose Fiscal Period selection...

Peter 

swuehl
MVP
MVP

Peter,

it's not a nested aggregation when you define your variable with a leading equal sign, so the variable will be replaced by the result, not the function.

Not applicable
Author

I tried both numeric and Date representation both doesn't work

Not applicable
Author

Please find the attached QVW file for example

swuehl
MVP
MVP

As said, you need to use a leading equal sign (which was missing in your app) in the variable definition and you need to create a number:

=num(min(uDAY))

in variable overview. Result of you expression is then 189.