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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
brunolelli87
Creator II
Creator II

Why my expression is not working?

Hello guys!

 

On a bar chart, I have the field STCK as Dimension, and the following expression:

 

=FirstSortedValue(VDAF, -DVPG)/(FirstSortedValue(LOPP, -PERI)/FirstSortedValue(NDAN, -PERI))

 

 

This expression is working perfectly!

Now, I'm trying to create a conditional expression that will show another bar when the user selects just one company (STCK). This new expression will calculate the average of the same expression based on the company's segment (SETO).
So, I created the following expression:

 

=avg(TOTAL{<STCK,SETO=p(SETO)>}(FirstSortedValue(VDAF, -DVPG)/FirstSortedValue(LOPP, -PERI)/FirstSortedValue(NDAN, -PERI)))

 

 
And the condition is:

 

GetSelectedCount(STCK) = 1

 



The expression is OK - with no errors - but shows nothing on a bar chart.
When I change the equation part of my expressions something like this:

=avg(TOTAL {<STCK,SETO=p(SETO)>}2/2)

Then, it shows... so I think there is a problem with my equation!

 

How can I solve it?
How can I show the average of the first equation based on the selected company's segment?

 

Thanks

1 Solution

Accepted Solutions
brunolelli87
Creator II
Creator II
Author

Hey, I got it!

This is what I did!

=AVG( TOTAL {<STCK,SETO=p(SETO)>}

AGGR(FirstSortedValue({<STCK,SETO=p(SETO)>}VDAF, -DVPG), STCK, SETO) /

	(
		AGGR(FirstSortedValue({<STCK,SETO=p(SETO)>}LOPP, -PERI), STCK, SETO) /
		AGGR(FirstSortedValue({<STCK,SETO=p(SETO)>}NDAN, -PERI), STCK, SETO)
	)

)

 

Thanks for this community!

View solution in original post

6 Replies
agigliotti
Partner - Champion
Partner - Champion

maybe this:
=Avg( TOTAL Aggr( ( FirstSortedValue(VDAF, -DVPG)
/
( FirstSortedValue(LOPP, -PERI)
/
FirstSortedValue(NDAN, -PERI) ) )
, STCK, SETO ) )

I hope it can helps.

brunolelli87
Creator II
Creator II
Author

Hello!

 

Thanks for your help... your expression works, but the result is not what I'm expecting.

Your expression is returning the same value always.

agigliotti
Partner - Champion
Partner - Champion

let's try to remove TOTAL keyword.

brunolelli87
Creator II
Creator II
Author

Hello!

Thanks for your help, but it's still not working!

 

Any other idea?

brunolelli87
Creator II
Creator II
Author

Hello guys

Any other idea?

brunolelli87
Creator II
Creator II
Author

Hey, I got it!

This is what I did!

=AVG( TOTAL {<STCK,SETO=p(SETO)>}

AGGR(FirstSortedValue({<STCK,SETO=p(SETO)>}VDAF, -DVPG), STCK, SETO) /

	(
		AGGR(FirstSortedValue({<STCK,SETO=p(SETO)>}LOPP, -PERI), STCK, SETO) /
		AGGR(FirstSortedValue({<STCK,SETO=p(SETO)>}NDAN, -PERI), STCK, SETO)
	)

)

 

Thanks for this community!