Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
gautik92
Specialist III
Specialist III

Variance for YTD

How to calculate the variance of YTD as i have YTD(Current year) and YTD(Previous Year)

1 Solution

Accepted Solutions
Not applicable

Variance:

sum({<Year={$(=Max(Year))},Transactiondate={"<=$(=max(Transactiondate))"}>

-

<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty)

Variance Percentage:

sum({<Year={$(=Max(Year))},Transactiondate={"<=$(=max(Transactiondate))"}>

-

<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty)

/

Fabs(Sum({<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty))

View solution in original post

11 Replies
Not applicable

Hi,

we have current year data we can cal it as YTD,previous year data we can cal it as a PYTD

Plz find the master calender link you vl get more information.

Creating A Master Calendar

gautik92
Specialist III
Specialist III
Author

I Want to find variance that is GAP for Current and previous year YTD

Kushal_Chawda

You can calculate as

(YTD- PYTD)/ PYTD

gautik92
Specialist III
Specialist III
Author

Can we do it for Sum(sales)

i found YTD by using YTD==sum({<Year={$(=Max(Year))},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty)

LY YTD==sum({<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty)

now how can i calculate Variance

Kushal_Chawda

(sum({<Year={$(=Max(Year))},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty)  - sum({<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty ) /

sum({<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty )

Not applicable

Variance:

sum({<Year={$(=Max(Year))},Transactiondate={"<=$(=max(Transactiondate))"}>

-

<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty)

Variance Percentage:

sum({<Year={$(=Max(Year))},Transactiondate={"<=$(=max(Transactiondate))"}>

-

<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty)

/

Fabs(Sum({<Year={$(=Max(Year)-1)},Transactiondate={"<=$(=max(Transactiondate))"}>} Qty))

Not applicable

As you can see the expression above contain differential analysis in the same Sum function.

That syntax is clean and powerful.

gautik92
Specialist III
Specialist III
Author

Its is not working but thanks man

Kushal_Chawda

Can you post some sample data?