Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone
Could someone explain so I understand QV logic better why this is:
Not a working formula
Count({$<[so_order_date_YYYYMM]={">=$(=min(date($(vPeriod3),'YYYYMM')))<=$(=max(date($(vPeriod4),'YYYYMM')))"},so_order_date_month={$(vExp_Selected_Date_Month)},$(vExp_Unselect_datefields),
If($(vShowUSLogic)=0,$(vStock),$(vStockUS)),$(vExternalClients),$(vExcludingArticleTypes)>} so_ordernumber)
and this:
Working formula
=If($(vShowUSLogic)=0,Count({$<[so_order_date_YYYYMM]={">=$(=min(date($(vPeriod3),'YYYYMM')))<=$(=max(date($(vPeriod4),'YYYYMM')))"},so_order_date_month{$(vExp_Selected_Date_Month)},$(vExp_Unselect_datefields),
$(vStock),$(vExternalClients),$(vExcludingArticleTypes)>} so_ordernumber) ,
Count({$<[so_order_date_YYYYMM]={">=$(=min(date($(vPeriod3),'YYYYMM')))<=$(=max(date($(vPeriod4),'YYYYMM')))"},so_order_date_month={$(vExp_Selected_Date_Month)},$(vExp_Unselect_datefields),
$(vStockUS),$(vExternalClients),$(vExcludingArticleTypes)>} so_ordernumber))
vStock & vStockUS are just variables containing a selection: delivertime_desc={'A','B','C'}
Attached
I've modified your variables so now only the box on top right works but that's expected
Lorenzo
You can initiate highlighted one is vShowUSLogic??
Count({$<[so_order_date_YYYYMM]={">=$(=min(date($(vPeriod3),'YYYYMM')))<=$(=max(date($(vPeriod4),'YYYYMM')))"},so_order_date_month={$(vExp_Selected_Date_Month)},$(vExp_Unselect_datefields),
If($(vShowUSLogic)=0,$(vStock),$(vStockUS)),$(vExternalClients),$(vExcludingArticleTypes)>} so_ordernumber)
Not working how? Incorrect numbers or zero or error?
Its really hard to debug an expression like this using so many variables, any one of which may or may not be contributing to the problem. The correct way to debug and fix this is to replace all the variables with the expected values, and remove selections and other elements that are not part of the problem. When its working, then re-insert the variables one at time to confirm that the variables are working as expected.
That said, Count(...If()) and If(Count(...)) are logically different operations.
Count(...If()) will iterate over the value and include only those that match the If() condition,
If(,,,(Count()) will only evaluate (over all values) if the condition is met, otherwise it will be null
@Jonathan: well it will gives me no value.
I did as suggested until I removed all variables.Still I have the same result:
Does not work
Count({$<If($(vShowUSLogic)=0,$(vStock),$(vStockUS))>} so_ordernumber)
Works:
If($(vShowUSLogic)=0,Count({$<$(vStock)>} so_ordernumber),Count({$<$(vStockUS)>} so_ordernumber))
FYI vShowUSLogic=if(LOG_Company='USCompany' and $(vUSLogicActive)=1 and Count(DISTINCT so_branch)>1,1,0)
vUSLogicActive is just a button that users can toggle so it will give 0 or 1
When the variable is just Toggle This won't work as expected. Because Left side condition won't work in Set analysis.
So even if the variable works perfectly, should I avoid using it in the set expression?
Also to the point of Jonathan:
That said, Count(...If()) and If(Count(...)) are logically different operations.
What can I do, to get the result I want?
Why don't you just put this "=If($(vShowUSLogic)=0,$(vStock),$(vStockUS))" into a separate variable that you then call in your set expression?
>>@Jonathan: well it will gives me no value.
Variables work great in set expressions - I use them all the time. But I develop complex expressions like this:
And no, you did not remove the variables,
Count({$<If($(vShowUSLogic)=0,$(vStock),$(vStockUS))>} so_ordernumber)
And
Does not work
gives no information about how to fix your expressions
Hi Lorenzo
That really seems a good idea. However my formula would not calculate. It seems like it is impossible to replace the variable.
Hi all
Thanks for all your patience so far!
I really downsized the problem to a ridiculously simple example attached.
As you can see, both variables ( true and false variable) work, as does the condition variable. In the example attached you can see '53' or '73' as values. Basically I want to be able to switch between the 2.
Please note that ,referring to my original post, simply changing the formula to
=If($(vShowCondition)=0,Sum({$<$(vRepSel1)>}Amount),Sum({$<$(vRepSel2)>}Amount)) is not what I am looking for.