Hello Everyone,
I have a difficulty figuring this one.
I have a dataset with product costs in different countries and the objective is to create a measure or calculated column to pick cost from particular country in this order:
First pick costfrom Mexico, if no cost in Mexico - pick cost from USA, in case there is no cost in USA, pick cost from Canada.
The idea is to follow this order. Cost value is not important so using MAX over columns is not the goal here.
Accomplishing this task with excel formulas is pretty easy. Below is the first solution that came into my head and I am sure there are tons more if you really think about it. However, recreating this in DAX is turning to be a challenge. If you have any ideas how to do this in DAX or any other ideas how to come close to the solution please share your thoughts.
This is a simple excel formula =IF(ISNUMBER(H3),H3,IF(ISNUMBER(I3),I3,G3))
Below are two tables: left is the dataset and on the right is the pivot table and the final result i am looking for in DAX (column FORMULA (in red)
Here is the link for excel spreadsheet: https://1drv.ms/x/s!AtVaiaKuHugAoijOlqDQtPqCnP1o
<colgroup><col><col><col><col><col><col><col span="2"><col><col span="5"></colgroup><tbody>
</tbody>
I have a difficulty figuring this one.
I have a dataset with product costs in different countries and the objective is to create a measure or calculated column to pick cost from particular country in this order:
First pick costfrom Mexico, if no cost in Mexico - pick cost from USA, in case there is no cost in USA, pick cost from Canada.
The idea is to follow this order. Cost value is not important so using MAX over columns is not the goal here.
Accomplishing this task with excel formulas is pretty easy. Below is the first solution that came into my head and I am sure there are tons more if you really think about it. However, recreating this in DAX is turning to be a challenge. If you have any ideas how to do this in DAX or any other ideas how to come close to the solution please share your thoughts.
This is a simple excel formula =IF(ISNUMBER(H3),H3,IF(ISNUMBER(I3),I3,G3))
Below are two tables: left is the dataset and on the right is the pivot table and the final result i am looking for in DAX (column FORMULA (in red)
Here is the link for excel spreadsheet: https://1drv.ms/x/s!AtVaiaKuHugAoijOlqDQtPqCnP1o
ProductID | Country | Cost | |||||||||||
1 | USA | 2.15 | Row Labels | CANADA | MEXICO | USA | FORMULA | ||||||
Product 1 | CANADA | 2.37 | Product 3 | 2.11 | 2.11 | =IF(ISNUMBER(G3),G3,IF(ISNUMBER(H3),H3,F3)) | |||||||
Product 2 | USA | 3.16 | Product 1 | 2.37 | 2.15 | 2.15 | |||||||
Product 2 | CANADA | 3.16 | Product 10 | 3.95 | 1.58 | 2.37 | 1.58 | ||||||
Product 2 | MEXICO | 3.16 | Product 11 | 1.58 | 3.95 | 3.16 | 3.95 | ||||||
Product 3 | CANADA | 2.11 | Product 12 | 2.84 | 1.99 | 1.99 | |||||||
Product 4 | USA | 3.16 | Product 2 | 3.16 | 3.16 | 3.16 | 3.16 | ||||||
Product 4 | CANADA | 3.95 | Product 4 | 3.95 | 3.16 | 3.16 | 3.16 | ||||||
Product 4 | MEXICO | 3.16 | Product 5 | 1.58 | 3.95 | 3.95 | |||||||
Product 5 | USA | 3.95 | Product 6 | 2.37 | 2.37 | ||||||||
Product 5 | CANADA | 1.58 | Product 7 | 3.16 | 2.37 | 3.16 | 2.37 | ||||||
Product 6 | USA | 2.37 | Product 8 | 1.58 | 3.95 | 3.95 | |||||||
Product 7 | USA | 3.16 | Product 9 | 3.16 | 3.16 | ||||||||
Product 7 | CANADA | 3.16 | |||||||||||
Product 7 | MEXICO | 2.37 | |||||||||||
Product 8 | CANADA | 1.58 | |||||||||||
Product 8 | MEXICO | 3.95 | |||||||||||
Product 9 | USA | 3.16 | |||||||||||
Product 10 | USA | 2.37 | |||||||||||
Product 10 | CANADA | 3.95 | |||||||||||
Product 10 | MEXICO | 1.58 | |||||||||||
Product 11 | USA | 3.16 | |||||||||||
Product 11 | CANADA | 1.58 | |||||||||||
Product 11 | MEXICO | 3.95 | |||||||||||
Product 12 | CANADA | 2.84 | |||||||||||
Product 12 | MEXICO | 1.99 |
<colgroup><col><col><col><col><col><col><col span="2"><col><col span="5"></colgroup><tbody>
</tbody>
Last edited: