Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

Expression error

Hi,

Not sure why this expression is giving me error.

Even I have all the right field and the right selection

Sum({<[Year of Expense] = {$(varPlReportingYear)},

          [Expense Type (annual)] = {"*Rent*"} or GetFieldSelections(_ShowRentFlag)=1

          >} [Amount of Expense (USD-annual)])

I apprciate any help!

1 Solution

Accepted Solutions
Not applicable

Well if you have got this qvw working then I am not sure what data model is affecting when you merge this to the main Dashboard.

However, I have attached the method in which you can control the displaying Dimensions based on the toggle.

Hope this helps.

View solution in original post

14 Replies
jvitantonio
Luminary Alumni
Luminary Alumni

Can you be more specific please? Can you attach a screenshot with your formula or paste it here?

whiteline
Master II
Master II

Because of this:

Sum({<[Year of Expense] = {$(varPlReportingYear)}, [Expense Type (annual)] = {"*Rent*"} or GetFieldSelections(_ShowRentFlag)=1>} [Amount of Expense (USD-annual)])

What do you want to calcualte?

Not applicable

You are not using an IF condition, then how come you are using an OR operator in your expression?

I don't think you can use a OR operator in SET Analysis.

alec1982
Specialist II
Specialist II
Author

Hi,

Thank you for the reply,

The expression in different way is :

Sum(if ( ((Index([Expense Type (annual)], 'Rent') = 0) or GetFieldSelections(_ShowRentFlag)=1)

                and ([Year of Expense] = $(varPlReportingYear))

            , [Amount of Expense (USD-annual)]

            )

        )

This doesn't give me error but It doesn't give me the right nr.

Anyway, I can write the expression differently than this?

Thxs,

alec1982
Specialist II
Specialist II
Author

The Get field selection is a toggle that  include/ exclude one of the dimension values.

The chat that I have is a bar chart that show expenses by expense type such as rent, parking,..

the toggle is to include/ exclude the rent bar.

Thxs,

Not applicable

I would suggest you to remove the check in expression and include it in Dimension.

Make it a calculated dimension with a 'IF' clause and make it NULL in case the flag is selected.

alec1982
Specialist II
Specialist II
Author

Thxs for the reply,

may you please give me more details or do you have any sample.

Thxs,

Not applicable

Very simple example is attached.

If you are looking for a different approach, feel free to attach a dummy dashboard to work on.

alec1982
Specialist II
Specialist II
Author

Hi,

Thank you for the sample. but it didnt fix my issue

I have exported the table into an excal file and created a new qvw and loaded the data and copied the same chart in it.

In the new QVW everything is loading correctly!  and the numbers are correct.

but on the requiered one, Numbers are not correct!

Any idea on what could be effecting the chart to not calculate correctly?

Attached is the new qvw.

Thxs