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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Find value of field a when field b is equal to variable 1?

Does anyone know how to find value of field a when field b is equal to variable 1 and store that result as a variable?

Regards,

4 Replies
swuehl
MVP
MVP

I assume there is an unambiguous value for a when b equals variable1, then you might try something like

=only({<b = {'$(variable1)'}>} a)

as variable definition in variable overview.

Hope this helps,

Stefan

Not applicable
Author

Variable thats still giving me a null (My goal to fix):

=only({<[Time-Date] = {'$(vMinTime)'}>}[Adj. Close])

vMinTime (Variable 1):

=min([Time-Date])

swuehl
MVP
MVP

Two things that come to my mind:

- ensure that the format of your variable matches the text format of your field, i.e. maybe you need to format the variable like

=timestamp(min([Time-Date]),'YYYY-MM-DD hh:mm:ss')

- Are there possibly multiple values of [Adj. Close] for the min [Time-Date]? If so, which value do you want to be returned?

Not applicable
Author

The format automatically changes to numeric i think in these evaluations.  I know that the vMinTime variable is numeric.  I've also tried num([Time-Date]) = {'$(vMinTime)'}   and [Time-Date] = {'$(vMinTime)'} with timestamp(min([Time-Date]),'YYYY-MM-DD')  for my vMinTime variable.  There are multiple [Adj. Close] for each vMinTime, one for each Ticker, but I make a selection of only one ticker value so should only be one possible value of Adj. Close)