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

Query Please help

Hi All,

I want to calculate like below

Year               Month               Average Salary         Previous Salary + Average Salary

2010                Jan                   15000                        15000

2010                Feb                   20000                        35000

2010                March               16000                         36000

like this

I reached till average salary ......but what function i should  have to used for Previous + average ....I am calculating this in chart Expression I used Last() function as well .....but did not work..

Help in this regards

Sarfaraz Sheikh

21 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Use this expression

=Avg(SALARY) + Alt(Above( TOTAL Avg(SALARY),),0)

Regards,

jagan.

Not applicable
Author


Thanks a lot mr anbu.....i got the solution as expected ...........can you please explain about the alt function ...what it does actually ...i am not familier with this function ....

Sarfaraz

Not applicable
Author

Thanks to all ..........I got the solution ...but what is alt functin ....what are its functionality request with all you guys to explain me in brief....

Sarfaraz

Not applicable
Author

Hi sarfaraz,

could you please post the solution as I was also trying the same but could not achieve it. I am using personal edition.

Thanks

anbu1984
Master III
Master III

From QV help

The alt function returns the first of the parameters that has a valid number representation. If no such match is found, the last parameter will be returned. Any number of parameters can be used.

Alt(Above( TOTAL Avg(SALARY),),0) -- In case of first row, Above() returns null. So Alt(Above(),0) returns last parameter 0.

Not applicable
Author

alt(sales,0)   it ignore null values

alt(date(date#(datefield,mm/dd/yyyy)),date(date#(datefield,mm-dd-yyyy))

it returns the correct date among this

Not applicable
Author

extract from help:

The alt function returns the first of the parameters that has a valid number representation. If no such match is

found, the last parameter will be returned. Any number of parameters can be used.

Example:

alt( date#( dat , 'YYYY/MM/DD' ),

date#( dat , 'MM/DD/YYYY' ),

date#( dat , 'MM/DD/YY' ),

'No valid date' )

Not applicable
Author

Hi Pooja,

Please check the above attched QVW file given by anbu cheliyan.........That will clear your doubts...

Sarfaraz

Not applicable
Author

I can not open qvw  created by other user.

could you please attach it as image so that i can also understand how this requirement achieved.

or if it achieved by any set expression could you please copy that set expression in this thread.

Thanks

Not applicable
Author

Dear Pooja,

please have the look on attached image.......

Solution.png

Sarfaraz