Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Issue on FieldValue

Hi all,

I've got some trouble to build a simple chart.

Here the data I have :

IDClientProductNumMouvementStock value
1C1P11000110
2C1P1100028
3C1P11000315
4C1P2100042
5C2P150028
6C2P1500410

It's quite simple, it represents all the mouvement I have on my stock for each client and product.

I want to have for each Client and product my final stock.

Something like that :

ClientProductFinal  stock
C1P115
C1P22
C2P110

I first tried to build my chart like that :

ClientProductMax(NumMouvement)only( {...}  StockFinal)
C1P110003-
C1P2100042
C2P15004-

Client and Product are dimensions

The two last columns are expressions. The last one use a set analysis : {$<NumMvt={$(max(NumMvt))}>}

You can see the problem, the max in the set analysis is interpreted by 10004 so it doesn't work for the first and last lines of the chart.

Then I tried to use the FieldValue and FieldIndex functions. With FieldIndex I get the number of the line in my data, the I use this number to get the stock value  corresponding to this line. I war really happy with this solution until I see that the number of the line depends on the field with a distinct filter.

For example, if I take my first chart and I try to do a FieldValue('NumMouvement',6) I will have 5004. That is correct.

But if I try to do a FieldValue('stock value',6), I will have nothing because there is less than 6 distinct value in this field.

I hope I was clear on my problem and hope someone can help me on that.

Regards,

Guillaume

1 Solution

Accepted Solutions
Not applicable
Author

you can try the next expresion: firstsortedvalue([Stock value], -NumMvt). This return the numbers you need but i dont know if in more complex calculation will work.

View solution in original post

3 Replies
Not applicable
Author

you can try the next expresion: firstsortedvalue([Stock value], -NumMvt). This return the numbers you need but i dont know if in more complex calculation will work.

Not applicable
Author

Can be a good way to solve my problem.

I just need to have a LastSortedValue car FirstSortedValue returns the oldest mouvement in my stock I want the last one.

Not applicable
Author

I didn't see the - before NumMvt.

It seems to work on simple calculation, I'll test it on something more complex.

Thanks