Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

What is wrong in my if?

Hello,

I am trying to manage to get my IF to work .. The problem is, that it does not really sum my sum() values in table 😕

If I use text-box object and the sum() values without if, then it sum() the values correctly without any problem . But even if I put the IF to text-box, it returns 0.

I am using the code below, I made some changes on the names...

If there is anyone who can help me with this, it would be much appreciated! !

=

// IF USER HAS NOT MADE ANY SELECTIONS OR SELECTED ALL OF THE 3

if(Count(distinct SourceName)=3,

// IF THERE IS NOT ANY SELECTIONS, WE WILL SUM THE A,B AND C WITH FILTERS

(sum({$<SourceName ={'*'} - {'C'}>} VALUE)) + (sum({<[FILTER1]={'BANANA'}, [FILTER2] = {">$(=-100)<$(=100)"}, SourceName={'C'}>} VALUE))

,

// IF ONE SOURCE HAS BEEN SELECTED AND IT IS C

if(Count(distinct SourceName)=1, if(WildMatch(lower(GetFieldSelections(SourceName)),'*c*'),

// IF IT IS 1 AND IT IS C

(sum({<[FILTER1]={'BANANA'}, [FILTER2] = {">$(=-100)<$(=100)"}, SourceName={'C'}>} VALUE)),

// IF IT IS 1 AND IT IS NOT C

(sum(VALUE))),

// IF THE SELECTION IS DIFFERENT THAN 3 OR 1 (IN THIS CASE 2)

// IF THE C IS WITHIN SELECTIONS

if(WildMatch(lower(GetFieldSelections(SourceName)),'*c*'),

// IF THE SELECTIONS INCLUDE ALSO A

if(WildMatch(lower(GetFieldSelections(SourceName)),'*a*'),

(sum({<SourceName = {'A'}>} VALUE))

+ (sum({<[FILTER1]={'BANANA'}, [FILTER2] = {">$(=-100)<$(=100)"}, SourceName={'C'}>} VALUE))

,

// IF THE OTHER SELECTION INCLUDES B

if(WildMatch(lower(GetFieldSelections(SourceName)),'*b*'),

(sum({$<SourceName = {'B'}>} VALUE)) + (sum({<[FILTER1]={'BANANA'}, [FILTER2] = {">$(=-100)<$(=100)"}, SourceName={'C'}>} VALUE)))),

// IF THE C IS NOT INCLUDED IN THE SELECTIONS

(sum(VALUE))

)))

The red part of the code is the one that does not work correctly on my table .. Actually it does the sum() values right on text-box for some reason.

Cheers,

Niko

13 Replies
Not applicable
Author

That did not have any influence on to that  😕

And I can't share this workbook with this data, and I do not know if I can re-produce this with the sampledata. Have to take a look on to that on some point.

Thanks anyway!

Cheers,

Niko

Not applicable
Author

For some reason when selecting all of the 3 options also, it does only show the sourcename C data.. And when nothing is selected, it shows all the data.

rubenmarin

When you say opposite is in both cases? Maybe the first condition is also true because the value wich is true for '*c*' or '*b*' is also true for '*a*'. Putting the '*' will return true if the substring is present in the other values.

If not: Can you upload a simple wich demostrates the issue? It doen't needs to have real data, just sample data simulating your document. (I don't have a QV available right now but I will have in a few hours)

Not applicable
Author

Well I did not crack that case, but I made a whole new IF-clause that works (at least now).

I could share that for example tomorrow

Still wondering why that earlier did not work...

Cheers,

Niko