Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

OmarBenSalem
Esteemed Contributor

Compare variable value to field value ..?

Hi all, stalwar1

I have a variable defined as follow:

UserID:  =subfield(osuser(),'\',1)  : since I'm using the desktop; its value is : Me

I have a table containing all user Ids and their names:

example:

Load * inline [

UT, UserName

Me, Omar Ben Salem   

Other, other user

];


What I want is to update my variable from Me to Me (Omar Ben Salem) : which is

Smiley Frustratedubfield(Osuser(),'\',1)&' ('& UserName of UT = Subfield(Osuser(),'\',1) &')'


What I did is this:

=Subfield(Osuser(),'\',1)&'('& aggr(Only({<UT ={"$(=UserID)"}>} UserName ),UserName)&')'


It partially works but it returns :

Capture.PNG


Why it's returing the Me() thing? I just want it to return Me (Omar Ben Salem)


Hope the explanation of my problem is clearer than the thread's title

Thanks !


1 Solution

Accepted Solutions

Re: Compare variable value to field value ..?

May be try this

If(Len(Trim(aggr(Only({<UT ={"$(=UserID)"}>} UserName ),UserName))) > 0, Subfield(Osuser(),'\',1)&'('& aggr(Only({<UT ={"$(=UserID)"}>} UserName ),UserName)&')')

Or this

Aggr(Subfield(Osuser(),'\',1)&'('& Only({<UT ={"$(=UserID)"}>} UserName )&')',UserName)

12 Replies
OmarBenSalem
Esteemed Contributor

Re: Compare variable value to field value ..?

Ps: I can always transform my expression into :

= if(len(aggr(Only({<UT ={"$(=Subfield(Osuser(),'\',1))"}>} UserName ),UserName))=0,null(), Subfield(Osuser(),'\',1)&'('& aggr(Only({<UT ={"$(=Subfield(Osuser(),'\',1))"}>} UserName ),UserName)&')')


and it would work:

Capture.PNG

I just want to know why It's returning the Me() value with my first expression ?

Re: Compare variable value to field value ..?

May be try this

If(Len(Trim(aggr(Only({<UT ={"$(=UserID)"}>} UserName ),UserName))) > 0, Subfield(Osuser(),'\',1)&'('& aggr(Only({<UT ={"$(=UserID)"}>} UserName ),UserName)&')')

Or this

Aggr(Subfield(Osuser(),'\',1)&'('& Only({<UT ={"$(=UserID)"}>} UserName )&')',UserName)

OmarBenSalem
Esteemed Contributor

Re: Compare variable value to field value ..?

Thanks Sunny, I already used the first expression; and as I told you, I wanted to know why It's returning the Me () ?

although, I'm thinking that in the expression it's clear that I just want to return to UserName where my UT = Me (the subfield thing)

Re: Compare variable value to field value ..?

Not sure how your data is, but if there are any null rows USERNAME with the way you data is connected, it will created (ME) for those rows....

OmarBenSalem
Esteemed Contributor

Re: Compare variable value to field value ..?

Nope;

It's a test I'm performing with this inline table:

load * Inline [

UT,UserName

Me,Omar Ben Salem

Other, Other

];

Capture.PNG

tht's why I'm confused ..

Re: Compare variable value to field value ..?

What if you test with just this

load * Inline [

UT,UserName

Me,Omar Ben Salem

];

OmarBenSalem
Esteemed Contributor

Re: Compare variable value to field value ..?

Capture.PNG

I just experienced a very weird behaviour !!!

I havn't closed my Qlik Sense Desktop since 31/11/2017:

When as a filter, I put date(today()) I have 31/11/2017 !!!

When I closed Qlik Sense et reopened it; it changed to 02/11/2017 !!

That's REAAAALLY WEIRD; mto‌ ; any explanation? Are u aware of such a thing??

OmarBenSalem
Esteemed Contributor

Re: Compare variable value to field value ..?

+: QLIK SENSE is aware that these 2 "31/10/2017" are not the SAME ; since It does not sum them up into one field :

Capture.PNG

That's something that could affect my whole project !

Re: Compare variable value to field value ..?

May be use Today(1)... look here for explanation

today ‒ QlikView

Community Browser