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

Dual function and how it goes underneath

Hello

Could someone please describe what happened in this dual expression?

=Dual(Num(Sum(Quantity), '#,###.') & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%'), Sum(Quantity))

As far as I know, Dual creates both text and numeric value out of single field/variable, and structure looks like DUAL(text, numeric), however in this expression there are three sections:

(Num(Sum(Quantity), '#,###.') - I guess its going to be first value, integer stored as a text

Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%') - this is going to be second value, numeric, percentage

Sum(Quantity)) - I am completely blunt with this one.  This refers to let Y axis be sum of quantity? Just a blind guess.. and without this, the expression has an error. How one could know, it is necessary, can you share knowledge behind this?

Thank you in advance

Labels (2)
8 Replies
MayilVahanan

Hi 

Dual function, we need to pass 2 parameter , one is text and another one is num

Based on ur expression, 

=Dual(Num(Sum(Quantity), '#,###.') & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%'), Sum(Quantity))

Text: Num(Sum(Quantity), '#,###.') & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%')

Num: Sum(Quantity)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
tresesco
MVP
MVP

It actually has two sections.

=Dual(Num(Sum(Quantity), '#,###.') & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%'), Sum(Quantity))

QlickySense
Creator
Creator
Author

Hey 

It does not evaluate three things?

I still dont get it . Lets assume in Quantity we have values of 3,2,1

=Dual(Num(Sum(Quantity), '#,###.')  - GIVES 6.000. & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%') - GIVES XXX % (this is not mine expression, i didn't brought Market variable), Sum(Quantity) - GIVES 6)

I got 3 results from that query, suppose to get two. How its going?

 

QlickySense
Creator
Creator
Author

It does not evaluate three things?

I still dont get it . Lets assume in Quantity we have values of 3,2,1

=Dual(Num(Sum(Quantity), '#,###.')  - GIVES 6.000. & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%') - GIVES XXX % (this is not mine expression, i didn't brought Market variable), Sum(Quantity) - GIVES 6)

I got 3 results from that query, suppose to get two. How its going?

MayilVahanan

Hi

FYI:

Sum(Quantity), '#,###.') - gives 6.00

Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%') - gives XX%

Num(Sum(Quantity), '#,###.') & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%')

gives 6.00 & XX% in text part

End result for your expression is : Dual( 6.00 & XX%, 6)

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
QlickySense
Creator
Creator
Author

You're right. What about the part highlighted in red? Without that this expression is wrong (i just changed variables to mine one)

=Dual(Num(Sum(Quantity), '#,###.') & Chr(10) & Num(Sum(Quantity)/Sum(TOTAL <Market> Quantity), '##.##%'), Sum(Quantity))

 

cwolf
Creator III
Creator III

I see a problem with your expression. The numerical value depends only on the Sum. The text depends on the Sum and the Total<Market>. Generally this won't work.

When creating duals, the following must be observed:

The relationship numerical value -> text value has to be unique. This means different texts cannot be assigned to the same numerical value.

On the other hand: The same text can be assigned to different numerical values.

For example:

TEST1:
LOAD Dual(F1,F2) as Dual1 INLINE [
F1, F2
A, 1
B, 2
C, 3
D, 3
E, 3
];

TEST2:
LOAD Dual(F1,F2) as Dual2 INLINE [
F1, F2
A, 1
B, 2
C, 3
C, 4
C, 5
];


The results:

cwolf_0-1632388821383.png

 

QlickySense
Creator
Creator
Author

Hi, 

That was expression from other thread

Mine expression is

DUAL(Num(count(Var1),'#.') & ' (' & Num(count(Var1)/count(TOTAL Var1),'0.0%')&')',count(Var1))
 
and it works, but this count(Var1) at the end must be contained otherwise I got an error in the expression. I dont have any set analysis or other thing here. For me, where I close parenthesis so &')' should be finish of the expression, but its not and that's why this thread has been created