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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to change dimension in Aggr function using Cyclic Group in expression?

I have a cyclic group and it has some of dimension such as KODYA,KECAMATAN,SUBBRANCH, and BRANCH.

This is my code in my expression :

if(YEAR_TRX = Max({<YEAR_TRX = {$(=Max(YEAR_TRX))}>} YEAR_TRX),

(Column(1) /

Aggr(NODISTINCT

Sum({$<ACTUAL_FLAG = {'*'} - {'0'}, ORG_ID = {'*'} - {'84'}>}

$(vActual)),

if(GetCurrentField("KecamatanGroup") = 'KECAMATAN', KODYA,

if(GetCurrentField("KecamatanGroup") = 'KODYA', SUBBRANCH,

if(GetCurrentField("KecamatanGroup") = 'SUBBRANCH', BRANCH,

if(GetCurrentField("KecamatanGroup") = 'BRANCH', BRANCH,

))))

)) * 100, 0)

Can someone explain to me why can't code work properly? This total result alwas 0.

I need to change my cyclic group "KecamatanGroup" so the value always be change.

Thanks

Labels (1)
1 Solution

Accepted Solutions
d_pranskus
Partner - Creator III
Partner - Creator III

Hi

Try this

if(YEAR_TRX = Max({<YEAR_TRX = {$(=Max(YEAR_TRX))}>} YEAR_TRX),

(Column(1) /

Aggr(NODISTINCT

Sum({$<ACTUAL_FLAG = {'*'} - {'0'}, ORG_ID = {'*'} - {'84'}>}

$(vActual)),

$(=if(GetCurrentField("KecamatanGroup") = 'KECAMATAN', 'KODYA',

if(GetCurrentField("KecamatanGroup") = 'KODYA', 'SUBBRANCH',

if(GetCurrentField("KecamatanGroup") = 'SUBBRANCH', 'BRANCH',

if(GetCurrentField("KecamatanGroup") = 'BRANCH', 'BRANCH',

)))))

)) * 100, 0)

Darius

View solution in original post

4 Replies
lironbaram
Partner - Master III
Partner - Master III

hi i dont think you can use a formula in the aggr part so try to replace

if(GetCurrentField("KecamatanGroup") = 'KECAMATAN', KODYA,

if(GetCurrentField("KecamatanGroup") = 'KODYA', SUBBRANCH,

if(GetCurrentField("KecamatanGroup") = 'SUBBRANCH', BRANCH,

if(GetCurrentField("KecamatanGroup") = 'BRANCH', BRANCH,

))))

with a variable which will hold the result of the formula above

d_pranskus
Partner - Creator III
Partner - Creator III

Hi

Instead of using if statements with GetCurrentField function, just use group name.

if(YEAR_TRX = Max({<YEAR_TRX = {$(=Max(YEAR_TRX))}>} YEAR_TRX),

(Column(1) /

Aggr(NODISTINCT

Sum({$<ACTUAL_FLAG = {'*'} - {'0'}, ORG_ID = {'*'} - {'84'}>}

$(vActual)), group_name

)) * 100, 0)

Not applicable
Author

I have use a variable but it can't work when i change dimension into cyclic.

vGroup =

if(GetCurrentField("KecamatanGroup") = 'KECAMATAN', KODYA,

if(GetCurrentField("KecamatanGroup") = 'KODYA', SUBBRANCH,

if(GetCurrentField("KecamatanGroup") = 'SUBBRANCH', BRANCH,

if(GetCurrentField("KecamatanGroup") = 'BRANCH', BRANCH,

))))

But when i change my Aggr function, it can't work.

d_pranskus
Partner - Creator III
Partner - Creator III

Hi

Try this

if(YEAR_TRX = Max({<YEAR_TRX = {$(=Max(YEAR_TRX))}>} YEAR_TRX),

(Column(1) /

Aggr(NODISTINCT

Sum({$<ACTUAL_FLAG = {'*'} - {'0'}, ORG_ID = {'*'} - {'84'}>}

$(vActual)),

$(=if(GetCurrentField("KecamatanGroup") = 'KECAMATAN', 'KODYA',

if(GetCurrentField("KecamatanGroup") = 'KODYA', 'SUBBRANCH',

if(GetCurrentField("KecamatanGroup") = 'SUBBRANCH', 'BRANCH',

if(GetCurrentField("KecamatanGroup") = 'BRANCH', 'BRANCH',

)))))

)) * 100, 0)

Darius