Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
i've this VBS code:
sub selectWeight
weight = ActiveDocument.Variables("vPeso").getcontent.string
x = CDbl(weight)
if x > 80 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Oltre gli 80 Q.li"
else if x > 60 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 80 Q.li"
else if x > 50 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 60 Q.li"
else if x > 40 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 50 Q.li"
else if x > 30 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 40 Q.li"
else if x > 25 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 30 Q.li"
else if x > 20 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 25 Q.li"
else if x > 15 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 20 Q.li"
else if x > 10 then
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 15 Q.li"
else
ActiveDocument.Fields("CATEGORIE PESO").Select "Fino a 10 Q.li"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end sub
is possible to translate in QlikView code?
Thank you
You can't put this in script, but it can be converted to an action.
I need to run this script for every row of pivot table, it's possible?
I don't think that makes sense.
What this script is doing is making a selection in a field.
If you run it on each row of a PT, the field selection will change; and when it's done only the last selection will be in effect.
Try this in a chart
=if($(vPeso) < 80,'Fino a ','Oltre gli ') & Rangemin(80,Floor($(vPeso),10)) & ' Q.li'
Cheers
Andrew
Yes, my idea doesn't work.
How can I make different choice for every row in a pivot table?
It doesn't work as I would like, because this expression writes the right thing, but I have to chosse the right category for every row in a pivot table
It's not really clear what do you want to do. Like mwoolf I think it makes not much sense and I suggest you prepared a small example with a few inline-data and how the output should be look like.
- Marcus
Ok, here a simple example.
I would this:
The user inserts the weight, in the pivot table will select the right TYPE based on the ROUND value and it will calculate the right price.
If you want a different expression for each row you will need a pick(match()) combination. The logic is quite similar to if-loops but it's more elegant, easier to maintain and more performant.
Whereby I would quite probably put these information within datamodel as an additionally field related to the CATEGORY and using then these field within your expressions.
- Marcus