Using a fileglobal variable in a superlookup queryformula

I have Database A with a fileglobal variable fgvar (a text value).
I have Database B with fields Invoice, DT, and Balance.
This formula in database A does not work even though I know that there is a record that should match.

superlookup("B",{DT="TI" and Invoice=fgvar},{Balance})

I assume the problem is that the scope of fgvar is the file A. Is there someway to make this formula work? Instead of using just fgvar, I tried constantvalue(“fgvar”) and datavalue(“fgvar”) in place of fgvar. That does not work.

Does anyone know how to solve this problem?

PS I did create a global variable with the same value as the fileglobal and that works. But it seems like that should not be necessary.

Use fileglobalvalue( in your formula.

1 Like

Thank you Gary.

Gary’s suggestion of fileglobalvalue( is my first choice for this as well. But there is another possible solution:

superlookup("B",{DT="TI" and Invoice=}+quoted(fgvar),{Balance})

It’s possible that this might be faster than using fileglobalvalue(, the only way to know for sure would be to time both methods.