Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Veq21984
Contributor II
Contributor II

How to properly write If, And, Or

Goal/s:

1. To get the Avg Price per Location.

2. To get the Avg Sales per Location

Given: Location: A, B, C, AB, ABC

Prices: Unique per Region

Sales: Unique for A, B, C; AB = A+B and ABC = A+B+C

 

My syntax For the Price:

If((Location ={''}+Location={'ABC'}),Avg({<Location = {'ABC'}>}Price),
If(Location ={'A'} and Location ={'B'},Avg({<Location = {'AB'}>}Price),Avg({<Location>}Price)))

My Syntax For the Sales:

If((Location ={''}+Location={'ABC'}),Avg({<Location = {'ABC'}>}Sales),
If(Location ={'A'} and Location ={'B'},Avg({<Location = {'AB'}>}Sales),Avg({<Location>}Sales)))

 

Any help would be greatly appreciated...

Labels (3)
3 Replies
sbaro_bd
Creator III
Creator III

Hi @Veq21984,

Can you give us a explanation ? For example, what are you trying to calculate with this expression : 

If((Location ={''}+Location={'ABC'}),Avg({<Location = {'ABC'}>}Price),
If(Location ={'A'} and Location ={'B'},Avg({<Location = {'AB'}>}Price),Avg({<Location>}Price)))

Thanks
Regards.

Veq21984
Contributor II
Contributor II
Author

Goal/s (See Expected Results sheets):

1. To get the Avg Price per Location.

2. To get the Avg Sales per Location

3. To get Total Sales per Location

4. To get Maximum & Minimum Demand, Price and Sales per Location

Given (See Data sheets):

Location Filter: A, B, C, AB, ABC

Prices: Unique value per Date per Location

Sales: Unique value per Date for Locations A, B, C;

For Location AB sales = Sales(Location A)+Sales(Location B)

For Location ABC sales = Sales(Location A)+Sales(Location B) + Sales(Location C)

Veq21984
Contributor II
Contributor II
Author

Goal/s (See Expected Results sheets):

1. To get the Avg Price per Location.

2. To get the Avg Sales per Location

3. To get Total Sales per Location

4. To get Maximum & Minimum Demand, Price and Sales per Location

 

Filters:

Location Filter: A, B, C, AB, ABC

Product Type: P01, P02,...,P09

 

Given (See Data sheets):

Prices: Unique value per Date per Location

Sales: Unique value per Date for Locations A, B, C;

For Location AB sales = Sales(Location A)+Sales(Location B)

For Location ABC sales = Sales(Location A)+Sales(Location B) + Sales(Location C)