Forum Discussion
Calculation DAX
- Anonymous1 year ago
Hi nesrinehal20
Please try the following possible solutions:
1. First, create the following measures to calculate total actual cost and pmp.
TotalActualCost = CALCULATE( SUM('OF'[actual cost]), ALLEXCEPT('OF', 'OF'[num_of]) )TotalPMP = CALCULATE( SUMX( 'OF', RELATED('PURCHASE'[pmp]) ), ALLEXCEPT('OF', 'OF'[num_of]) )2. Create the following measures to calculate consumption and material cost.
consumption = [TotalActualCost] * [TotalPMP]material cost = DIVIDE( [consumption], CALCULATE( SUM('PF'[quantity]), ALLEXCEPT('PF', 'PF'[num_of]) ) )Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You said that OF and PF are related by num_of but the images you shared of the data don't show that column.
Also we can't really work with images, providing data as tables or ideally providing the PBIX file you are using makes our jobs as volunteers much easier. Typing out all the data in your (incomplete) images takes some time and will be prone to errors, making the answers we give you no use.
Please check this which might explain things better than I have
Re: How to Get Your Question Answered Quickly - Page 7 - Microsoft Fabric Community
Regards
Phil
PURCHASE FILE
| code_article | designation | family | month | pmp |
| MPO0239 | acide citrique | MP | 1 | 3,71 |
| EMO2636 | Présentoir | EM | 2 | 3.5 |
OF FILE
| num_of | code_article | designation | famille | actual cost |
| OF2401-men001 | EM02636 | presentoir | EM | 1150 |
| OF2501-pro002 | MPO0239 | acide | MP | 120.5 |
PF FILE
| site | num_of | code_pf | designation_pf | quantity |
| men | OF2401-men001 | PFSN036 | Juto | 1500 |
| PRO | of2501-pro002 | PRO012 | choco | 200 |