Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Applicable88
Creator III
Creator III

Value list and if -order other way around not working

Hello,

I have a question regarding the order of value list. It took me a long time to find that the order in my formula is the problem. Note that I know I could have write the values list shorter, but since I want to keep the old structure of a colleague and also that I can refer to the old count function in the future I just reorganize the function.

Example:

I want to sum two counts of same Valuelist name and behind there are two other Value list names. After the sum of the first two the last two are written in the typical manner we all know from Valuelist function.

If(ValueList('Daily','Manual','Automatic')='Daily',
count({<[Date]={"=$(=today())"},[DeliveryId]={'UUUU'}>}[Deliverynumber])

+

If(ValueList('Daily','Manual','Automatic')='Daily',
count({<[Date]={"=$(=today())"},[OrderID]={'LLLL'}>}[Deliverynumber]), If(ValueList('Daily','Manual','Automatic')='Manual',
count({<[Date]={"=$(=today())"},[OrderID]={'BBBB'}>}[Deliverynumber], If(ValueList('Daily','Manual','Automatic')='Automatic',
count({<[Date]={"=$(=today())"},[OrderID]={AAAA'}>}[Deliverynumber],0))))

Because of the  the sum '+' of the first two if statements I get no returns for the other two if statments. 

Only when I do that other way around it seems to work, i.E. to put the sum of the first two statement at the end then it works:

If(ValueList('Daily','Manual','Automatic')='Manual', count({<[Date]={"=$(=today())"},[OrderID]={'BBBB'}>}[Deliverynumber], If(ValueList('Daily','Manual','Automatic')='Automatic',
count({<[Date]={"=$(=today())"},[OrderID]={AAAA'}>}[Deliverynumber], 
If(ValueList('Daily','Manual','Automatic')='Daily',
count({<[Date]={"=$(=today())"},[DeliveryId]={'UUUU'}>}[Deliverynumber])

+

If(ValueList('Daily','Manual','Automatic')='Daily',
count({<[Date]={"=$(=today())"},[OrderID]={'LLLL'}>}[Deliverynumber]),0))))

I also tried to put brackets somehwere, since it seems to be a problem with the order how the function is calculated. But nothing works out. 

Can someone spot the problem here?

Thanks in advance.

Best.

1 Solution

Accepted Solutions
jwjackso
Specialist III
Specialist III

I believe the bold was only executed for Daily.

If Daily Then expression1 + If Daily Then expression2 If Manual Then expression3 If Automatic Then expression4,0))))

What you wanted

If Daily Then expression1 + expression2,
  If Manual Then expression3,
    If Automatic Then expresion4,0)))

View solution in original post

3 Replies
jwjackso
Specialist III
Specialist III

Since you have already determined that the valuelist is equal to Daily, is the line in, strike through,  necessary?  Is the last count expression correct, in bold?

If(ValueList('Daily','Manual','Automatic')='Daily',
count({<[Date]={"=$(=today())"},[DeliveryId]={'UUUU'}>}[Deliverynumber])

+

If(ValueList('Daily','Manual','Automatic')='Daily',
count({<[Date]={"=$(=today())"},[OrderID]={'LLLL'}>}[Deliverynumber]), If(ValueList('Daily','Manual','Automatic')='Manual',
count({<[Date]={"=$(=today())"},[OrderID]={'BBBB'}>}[Deliverynumber], If(ValueList('Daily','Manual','Automatic')='Automatic',
count({<[Date]={"=$(=today())"},[OrderID]={AAAA'}>}[Deliverynumber],0))))

 

Revised:

If(ValueList('Daily','Manual','Automatic')='Daily',count({<[Date]={"=$(=today())"},[DeliveryId]={'UUUU'}>}[Deliverynumber]) + count({<[Date]={"=$(=today())"},[OrderID]={'LLLL'}>}[Deliverynumber]),
If(ValueList('Daily','Manual','Automatic')='Manual',count({<[Date]={"=$(=today())"},[OrderID]={'BBBB'}>}[Deliverynumber],
If(ValueList('Daily','Manual','Automatic')='Automatic',count({<[Date]={"=$(=today())"},[OrderID]={AAAA'}>}[Deliverynumber]),0)))

 

 

Applicable88
Creator III
Creator III
Author

Hi @jwjackso ,

thank you very much.  For giving me the tips. And the correction of the parenthesis.

My question at the end was still that the order of the first one didn't work, but other way round it gave me the values I needed.  Do you have any explanation for this? 

jwjackso
Specialist III
Specialist III

I believe the bold was only executed for Daily.

If Daily Then expression1 + If Daily Then expression2 If Manual Then expression3 If Automatic Then expression4,0))))

What you wanted

If Daily Then expression1 + expression2,
  If Manual Then expression3,
    If Automatic Then expresion4,0)))