How to return field name

Hi there how can I get the field name?

I am trying the following pseudo code in “Enter/Edit Expression” for a measure

if (variable in “field_name”, sum(variable), else pass/None )

The idea behind:
I have a custom drop down filter which holds variables. These variables are passed to a line chart as measure via sum(<variable::>). This works fine so far.

But now I want to sum, count, avg based on specific variable names. Any ideas?

@Umut885 You probably need to use a case statement similar to below that looks at what the “variable” contains and chooses the right aggregate to apply. Something like this:

CASE WHEN '<<variable>>'='sales' THEN avg(<<variable>>) 
WHEN '<<variable>>'='transaction' THEN sum(<<variable>>) 
1 Like

What if I do the same for secondary line in chart (colors) and for one of the cases I need to hide the line?

CASE WHEN '<<variable>>'='sales' THEN avg(<<variable>>) 
WHEN '<<variable>>'='transaction' THEN sum(<<variable>>) 
WHEN '<<variable>>'='something' THEN null // requires an aggrigate, but fails on null 

@Andrey_Korlyuk you could try something like this that will at least flatten the line at 0 when the “something” is clicked:

CASE WHEN '<<variable:sales>>'='sales' THEN avg(<<variable:0>>) 
WHEN '<<variable:sales>>'='profit' THEN sum(<<variable:0>>) 
WHEN '<<variable:sales>>'='discount' THEN max(0) END

You will have to make sure that “something” is an actual column name, otherwise this won’t work.