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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
segerchr
Contributor III
Contributor III

Win or draw where to script

Hey,

i have one field called Ergebnis. in this field there are a lot of summarys.

My goal is it, to show a bar graph with the sum of wins, draws and so on.

But where can I use this code ? Directly in the script or in the bar graph ?

//if (Heimspiel = 'x' and left(Ergebnis,1)> left(Ergebnis,3), 'WIN',if (Heimspiel = 'x' and left(Ergebnis,1)= left(Ergebnis,3),'Draw,'Lose'))

Thanks...

3 Replies
sunny_talwar

This?

Capture.PNG

Dimension:

None

Expression:

=Sum(If(SubField(Ergebnis, ':', 1) > SubField(Ergebnis, ':', 2), 1, 0))

=Sum(If(SubField(Ergebnis, ':', 1) < SubField(Ergebnis, ':', 2), 1, 0))

=Sum(If(SubField(Ergebnis, ':', 1) = SubField(Ergebnis, ':', 2), 1, 0))

segerchr
Contributor III
Contributor III
Author

Hi,

thanks for your answer.

In my datasource there are PlayerIDs and in the second line the results. Can i sum the result with an distinct or something else ?

My diagram should display one win and one draw 🙂

Thanks for helping

sunny_talwar

Assuming you have an identifier which show that first 4 rows are from one game and the next 4 are from the another game you can do it.

Sample data:

Load * inline [

PlayerID,Ergebnis, Heimspiel, GameID

ID001,0:0,x, 1

ID002,0:0,x, 1

ID003,0:0,x, 1

ID004,0:0,x, 1

ID001,1:0,x, 2

ID002,1:0,x, 2

ID003,1:0,x, 2

ID004,1:0,x, 2

];

Expressions:

=Sum(Aggr(If(SubField(Ergebnis, ':', 1) > SubField(Ergebnis, ':', 2), 1, 0), GameID))

=Sum(Aggr(If(SubField(Ergebnis, ':', 1) < SubField(Ergebnis, ':', 2), 1, 0), GameID))

=Sum(Aggr(If(SubField(Ergebnis, ':', 1) = SubField(Ergebnis, ':', 2), 1, 0), GameID))


Capture.PNG