Forum Discussion
Formula Dax -
Good morning,
I am trying to create a new column ( example below" created " column is the result I would like to get ). The new column should copy the value of the " DEN" column for each KPI ( taking into account the MARKET except for the KPI "NNS Aff" where it should change the value instead of zero it should take the value of NNS for the appropriate market.
KPI time Cluster Sub cluster Market C B. A num num-calc den den-c created
| NNS | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 5819,913 | 5819,913 | 0 | 0 | 0 |
| Sales PFME | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 240,0538 | 240,0538 | 5819,913 | 0 | 5819,913 |
| FFOH | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 698,0702 | 698,0702 | 5819,913 | 0 | 5819,913 |
| FFOH Int | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 538,5705 | 538,5705 | 5819,913 | 0 | 5819,913 |
| PRO | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | -145,042 | -145,042 | 5819,913 | 0 | 5819,913 |
| PRO Int | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | -156,0896 | -156,0896 | 5819,913 | 0 | 5819,913 |
| Dep FF | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 78,0237 | 78,0237 | 5819,913 | 0 | 5819,913 |
| Dep FF Int | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 101,4998 | 101,4998 | 5819,913 | 0 | 5819,913 |
| OPFE | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 26,2381 | 26,2381 | 5819,913 | 0 | 5819,913 |
| Bad Goods | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 6,6269 | 6,6269 | 5819,913 | 0 | 5819,913 |
| PC | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 2290,4445 | 2290,4445 | 5819,913 | 0 | 5819,913 |
| FDC | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 153,2392 | 153,2392 | 5819,913 | 0 | 5819,913 |
| Structural Costs | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 1332,2886 | 1332,2886 | 5819,913 | 0 | 5819,913 |
| NNS Aff | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 2189,4962 | 2189,4962 | 0 | 0 | 5819,913 |
| OP1 Aff | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 183,6664 | 183,6664 | 2189,4962 | 0 | 2189,4962 |
| Volumes | 2021 YTD - 02 | AOA Cluster | Oceania | Oceania | MN | Medical Nutrition | 616 | 616 | 0 | 0 | 0 |
- Anonymous4 years ago
Hi Anonymous ,
Please try below steps:
1.my test table
Table:
2. add a new column by below dax formula
Column = VAR cur_kpi = 'Table'[KPI] VAR cur_market = 'Table'[Market] VAR cur_numcalc = CALCULATE ( SELECTEDVALUE ( 'Table'[Num-calc] ), 'Table'[KPI] = "NNS", 'Table'[Market] = cur_market, ALL ( 'Table' ) ) RETURN IF ( cur_kpi = "NNS Aff", cur_numcalc, 'Table'[Den] )Please refer the attached .pbix file.
Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- AnonymousNot applicable
Hi Anonymous ,
Please try below steps:
1.my test table
Table:
2. add a new column by below dax formula
Column = VAR cur_kpi = 'Table'[KPI] VAR cur_market = 'Table'[Market] VAR cur_numcalc = CALCULATE ( SELECTEDVALUE ( 'Table'[Num-calc] ), 'Table'[KPI] = "NNS", 'Table'[Market] = cur_market, ALL ( 'Table' ) ) RETURN IF ( cur_kpi = "NNS Aff", cur_numcalc, 'Table'[Den] )Please refer the attached .pbix file.
Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Anonymous Thanks a lot !
- AntonioMSolution Sage
Hi Anonymous,
Your column headers have shifted around a bit so apologies if I've misunderstood but please give this a try.
Created = IF ( 'Table'[KPI] = "NNS Aff" , CALCULATE ( SELECTEDVALUE ( 'Table'[num-calc] ) , ALLEXCEPT ( 'Table','Table'[Market] ) , 'Table'[KPI] = "NNS" ) , 'Table'[den] )For NNS Aff it finds the value of 'num-calc' where 'Market' is the same. For all other KPIs it just copies across 'den'
- AnonymousNot applicable
hi AntonioM ,
I just tried and it is not working.
For "NNS Aff" it should find the value of 'num-calc' of the corresponding " NNS " where 'market' are the same. For all other KPIs it just copies across 'den'.
Thank you for your answer , I m still working on it.
Best regards,
A.