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

About variables (loading script) and calculating exp

Hello. I will try to describe an issue and hope someone could help me. I am new to it

1. I have a copy of a spreadsheet with formulas (textboxes and so one). Original project was fully functional. This project ( a copy i am speaking of) has a lot of variables, wich i need to add and recalulate.

Example.

I have a file (qvo) with such structure (let name be "Table1"):

value fild 1| value field2 | value field 3|

Yes                 asdasd              1111

No                   treasd               2231

 

So now i need to calc unique values of field2 and print them somewhere. I can do it like 

=Count(DISTINCT [value field2]) and it works good.

This is way i rewrite it

But originaly this was with variable like 

=(Count(DISTINCT $(vField2Count)) and it worked and did the same. 

It is dynamic. 

I think this Variable vField2Count was assigned like with every field of that column.Think it was loading at the load script.

I need to do it like this as this variables are using across all project. 

Hope you understand me. Thx

 

 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

Im sorry but your examples didn't help me to understand your issue. The script and the excel are not related.  Please explain.

Maybe I am over thinking your problem. YOu just want to manually declare the variable vField2Count? If so then just write this in your script.

LET vField2Count =  '[Value Field 2]'; 

View solution in original post

10 Replies
Vegar
MVP
MVP

What is the output of the  $(vField2Count)?

 

A) value field2

B) [value field2]

If A then you need to add brackets in your expressions like this:

=(Count(DISTINCT [$(vField2Count)]) 

alex900
Contributor II
Contributor II
Author

i dont know what is the output of this value as now a project for what it was imported didnt acceptable now.

but the output of Count(DISTINCT [value field2]) is equal ot (Count(DISTINCT $(vField2Count))  of previous project

so both of that expression should calculate unique values

I am sure  1000000% that the original expression was = Count(DISTINCT $(vCheckCount)) without [ ] 

alex900
Contributor II
Contributor II
Author

I think i should somehow assing vField2Count variable to each value of the fields wich i count..

so if my table is

value fild 1| value field2 | value field 3|

Yes                 asdasd              1111

No                   treasd               2231

my variable should be assigned with column " value field2"

smth like" value field2" = "vField2Count"

alex900
Contributor II
Contributor II
Author

Maybe to use Peek somehow?

Vegar
MVP
MVP

Is the field name the same as well? You only need brackets when you have field names with spaces, like [Field Name]. It's not necessary for fields without spaces like FieldName.

alex900
Contributor II
Contributor II
Author

i know it but it is not about i am asking of.

i dont know how to assing variable  "vField2Count" with values of field named " value 2 field"

 

 

alex900
Contributor II
Contributor II
Author

i understood about u telling but i did it already ( wrote about it at the 1st post)

but i want assing variable with field

alex900
Contributor II
Contributor II
Author

i uploaded file to understand it better what i mean

test.xlsx as date source but i think it is not neccesary

Vegar
MVP
MVP

Im sorry but your examples didn't help me to understand your issue. The script and the excel are not related.  Please explain.

Maybe I am over thinking your problem. YOu just want to manually declare the variable vField2Count? If so then just write this in your script.

LET vField2Count =  '[Value Field 2]';