Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
xavieravinson
Contributor III
Contributor III

using aggr function inside variable

Hi All,

        Shall i use the Aggr function inside the Variable.I have already tried the function inside the variable. It is working on selections. with out selection it is giving overall sum of the measure.

My Variable

      =Sum(Aggr(Budget,[Sales Off],Employee))

Sample Data Inline

LOAD * INLINE [

    Budget, Employee, Sales Off, Sales Grp

    10000, Xavier, 1001, 101

    15000, Antony, 1001, 102

    10000, Napolean, 1002, 103

    20000, Ravinson, 1002, 104

];

with Regards

XavieRavinson

18 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

what is the result you are looking for

as it's stand your function in variable will calculate the total sum of budget

but will do it by first creating a virtual table which will give less than ideal performance

inside a variable the expression sum(Budget) will give you the same results

Anil_Babu_Samineni

How about this? You should use this variable into Set Expression only

Aggr(sum([Sales Off]),Budget, Employee)

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
saimahasan
Partner - Creator III
Partner - Creator III

What type of output you are expecting?? What number should be calculated in the variable??

xavieravinson
Contributor III
Contributor III
Author

Hi Liron,

          Thanks for your reply.

My question is shall i calculate aggregated values using variables. If i use the aggr() function inside the expression i am getting correct value without any selections.

test.JPG

If i use the expression inside the Variable it is not giving the accurate result without selection.

xavieravinson
Contributor III
Contributor III
Author

Hi Anil,

           Sorry.Why Sum(Sales Off) I am not getting your answer.

With Regards

XavieRavinson

xavieravinson
Contributor III
Contributor III
Author

Hi Saima,

         Looking for a result test.JPG

like above without any selections.

Thank you

With Regards,

XavieRavinson.

Anil_Babu_Samineni

That gives Data point with the Aggr of Dims

Anyhow, I've seen below reply, I used Simple Sum(Budget) to get this

Without Selection

Capture.PNG

With Selection

Capture1.PNG

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
MK_QSL
MVP
MVP

I don't think you need AGGR function here.

Create a Straight Table.

Dimension

Employee

[Sales Off]

Expression

SUM(Budget)

Aggr is same as Group By in script.

Aggr will create a virtual table.

Please go through below two links to get better idea of Aggr function.

Pitfalls of the Aggr function

When should the Aggr() function NOT be used?

parimikittu
Creator II
Creator II

Hi, Why do you need to use aggr inside a variable to obtain above result. You can create a straight table with Dimensions(sales Grp, Employee) and measure as sum(Budget). If u still insist on using Aggr function use Aggr(sum(Budget),Sales Grp,Employee) as expression and  Dimensions(sales Grp, Employee).