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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
bhavvibudagam
Creator II
Creator II

Avg()

Hi Experts,

Can any one please help me on Creating a below Table with Avg Number of entities per Month with the below format.

table.png

Please find the below sample data from the source in inline script.

Load * inline [

Risk,Month, Entities

Low,Jan,5

Low,Feb,7

Low,Mar,2

Low,Apr,4

Low,May,3

Low,Jun,3

Low,Jul,5

Low,Aug,5

Low,Sep,0

]


In the Table first column need to show like

Jan-Feb, Mar-Apr, May-Jun,Jul-Aug

The calculation is like below   Jan+ Feb= 5+7 =12/2=6

                                               Mar+Apr = 2+4 =6/2 =3

                                               May+Jun= 3+3=6/2=3

                                               Jul  + Aug=5+5=10/2=5

                                   There is no Oct for adding with Sep so not showing in table.

Thanks in advance.

1 Solution

Accepted Solutions
jerryyang756
Creator
Creator

Using MonthOrder :

Load * inline [

Risk,Month, Entities,MonthOrder

Low,Jan,5,1

Low,Feb,7,2

Low,Mar,2,3

Low,Apr,4,4

Low,May,3,5

Low,Jun,3,6

Low,Jul,5,7

Low,Aug,5,8

Low,Sep,0,9

];

Now take a straight table and add dimension :

=Aggr(If(Odd(MonthOrder),Month &'-' & Below(Month)),Month)

Now Add the Expression:

=Aggr(If(Odd(RowNo()),(Sum(Entities)+Below(Sum(Entities)))/2),Month)

Capture1.PNG

View solution in original post

5 Replies
YoussefBelloum
Champion
Champion

Hi,

try this as an expression on a table:

=Only({<Month={'Feb','Apr','Jun','Aug'}>} aggr(RangeAvg(Above(Entities,0,2)),Month))

rubenmarin1

Hi Bhavani, you can add a field with the grouped months:

Left Join (InlineTableName)

LOAD * Inline [

Month, GroupedMonthName

Jan, Jan - Feb

Feb, Jan - Feb

Mar, Mar - Apr

Apr, Mar - Apr

....

];

Using GroupedMonthName and an expression like "Avg(Entities)" it should work

jerryyang756
Creator
Creator

Using MonthOrder :

Load * inline [

Risk,Month, Entities,MonthOrder

Low,Jan,5,1

Low,Feb,7,2

Low,Mar,2,3

Low,Apr,4,4

Low,May,3,5

Low,Jun,3,6

Low,Jul,5,7

Low,Aug,5,8

Low,Sep,0,9

];

Now take a straight table and add dimension :

=Aggr(If(Odd(MonthOrder),Month &'-' & Below(Month)),Month)

Now Add the Expression:

=Aggr(If(Odd(RowNo()),(Sum(Entities)+Below(Sum(Entities)))/2),Month)

Capture1.PNG

bhavvibudagam
Creator II
Creator II
Author

Hi Youssef,

Thanks for your reply. Getting the result like below. But business want to see the Month Column as Jan-Feb, Mar-Apr, May-Jun, Jul-Aug. is this possible to show the dimension like this in Front end without any changes in the backend.

table Result.png

Thanks in advance.

YoussefBelloum
Champion
Champion

Yes you can do this by using a calculated dimension

=if(Match(Month,'Jan','Feb'),'Jan-Feb',

if(Match(Month,'Mar','Apr'),'Mar-Apr',

if(Match(Month,'May','Jun'),'May-Jun',

if(Match(Month,'Jul','Aug'),'Jul-Aug', Month))))

PFA