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

Script and if statement

Can someone tell me why this script wont work?

 

LOAD

UserName,
FirstName,
LastName,
Title,
OU,
Department,
Location,
Emailaddress,
WhenCreated,
PaswordLastChanged,
LastLogonTime,

AccControl,
Status,
PasswordAge,
if ('PasswordAge' >='60'<='180', RGB (255,0,0), RGB (0,0,0)) as PasswordFlag,
AccountLockout,
AccountExpirationDate,
NextPwdReset,
MFID,
Description,
Manager,
SSO,
"NON_Human";

SQL ...

14 Replies
Not applicable
Author

I figured it out and used the today() variable.

Now I'm trying to make a button. So that when its clicked it will display all my red flagged values, and another for all the yellow values.

jjfabian
Partner - Creator III
Partner - Creator III

Well ...

you should try to make the button using a variable.

- Create a variable (I'd call it vPasswordAgeColor or something like that)

- Tell your red button to set the variable's value to the actual formula you used for the red color in your expression (to do this, select the External -set variable action in your button or text object) - make sure you put the entire formula in high commas

- do the thing vice versa for your yellow button

- Lastly, add the =vPasswordAgeColor as Color in your expression ... now you can toggle your colors via these buttons.

Alternatively, you could only put the color formula into the variable (eg. 'rgb(255,0,0)' )and replace them in your expression. But that's really a question of how you'd like to do this.

I handle most of my colors in the load script in the beginning. I define all my colors for diagrams, tabs, borders, highlights as 'rgb(xxx,xxx,xxx)' values there so it's easy to change things globally and achieve a high level of consistency.

Jakob

Not applicable
Author

So I just want to make sure I'm understanding this correctly.

So if I made two variables, one for red and one for yellow. vPasswordAgeRed and vPasswordAgeYellow.

Then used those variables in my nested if statements instead of actually putting the RGB (0,0,0) in it?

So then when I used the button I can just have it due the external search and put in the variable and it should pull up wherever that variable is used?

Thanks!

Not applicable
Author

I noticed you said you assign highlights in the script prior so that the highlights can be global.

So lets say I have an employee and their number is '123456789' and if their last logon time was over 120 days ago I want to flag them throughout the QVW no matter where they appear, can this be done? So that they're even flagged in table boxes where you cant use expressions.

Ultimately, I'm working on a security report. With multple tabs based on different applications and who has access to what applications.

I just need to make sure that a person who hasnt logged on is flagged everywhere in red.

jjfabian
Partner - Creator III
Partner - Creator III

Now that's something you probably can't do - at least I wouldn't know how to.

What I meant by global colors is adding them in the script as variables so you never have to think about them again - Example: Imagine you use a certain red color everywhere (fontcolors, headers, backgrounds, bar colors and so on) in your QVW --> vColor1. If you wanted to change to another color and used an rgb() function everywhere, well... have fun changing your rgb function everywhere. However, if you used vColor1 everywhere, all you would have to do is change your variable in the script ONCE.

So while you can't tag a field with a certain color you can at least ensure consistency by assigning the same color wherever you need it.