Forum Discussion

jyaul12's avatar
jyaul12
Frequent Visitor
3 years ago
Solved

Total by category

Dear Friend,

 

i have five client and calculated their Sell Qty,Avg 1 Avg2 group by date( using DAX).

 

Then i calculate Profit by formula: Sell Qty *(Avg1-Avg2). The value i am getting individual for each company are correct but when i see as total profit is different. If i will add all individual company one by one then Profit: -622058(which is correct). But Profit i am getting is: -1703848 as final value . how can i get -622058.

 

 

 

  • i solved it by measures:

    Profit =sumx(values(sheet1[companyid]), [Qty_A]*([Avg_A]-[Avg_B]))

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Try using a calculated column instead:

    Profit Measure Col =
    Sheet1[Sell QTY] * (Sheet1[AVG 1] - Sheet1[AVG 2])
     

     


     

     

    • jyaul12's avatar
      jyaul12
      Frequent Visitor

      Dear Sir, 

      I tried with calculated column but the calculated values are not correct.

      here are data:

       

      company_idvalueQtyQty typeDate
      1001251A02/05/2023
      1011265A02/05/2023
      1021276A02/05/2023
      1031289A02/05/2023
      10412910A02/05/2023
      10513025A02/05/2023
      10611536A02/05/2023
      10711625A02/05/2023
      10811722A02/05/2023
      10911811A02/05/2023
      11011914A02/05/2023
      10022122B02/05/2023
      10122255B02/05/2023
      10222311B02/05/2023
      10322447B02/05/2023
      10422559B02/05/2023
      10522665B02/05/2023
      10622736B02/05/2023
      10723925B02/05/2023
      10825598B02/05/2023
      10926612B02/05/2023
      11028855B02/05/2023
      1002503A03/05/2023
      10125215A03/05/2023
      10225418A03/05/2023
      10325627A03/05/2023
      10425830A03/05/2023
      10526075A03/05/2023
      106230108A03/05/2023
      10723275A03/05/2023
      10823466A03/05/2023
      10923633A03/05/2023
      11023842A03/05/2023
      10044266B03/05/2023
      101444165B03/05/2023
      10244633B03/05/2023
      103448141B03/05/2023
      104450177B03/05/2023
      105452195B03/05/2023
      106454108B03/05/2023
      10747875B03/05/2023
      108510294B03/05/2023
      10953236B03/05/2023
      110576165B03/05/2023

       

      and i used the measures:

      1. 

      Qty_A = CALCULATE(SUM(Sheet1[Qty]),Sheet1[Qty type]="A")
       
      2. 
      Qty_B = CALCULATE(SUM(Sheet1[Qty]),Sheet1[Qty type]="B")
      3.
      Value_A = CALCULATE(SUM(Sheet1[value]),Sheet1[Qty type]="A")
      4.
      Value_B = CALCULATE(SUM(Sheet1[value]),Sheet1[Qty type]="B")
       5.
      Avg_A = [Value_A]/[Qty_A]
      6.
      Avg_B = [Value_B]/[Qty_B]
       
      and finally formula for Profit is:
      Profit = [Qty_A]*([Avg_A]-[Avg_B])
       
      whenever i displayed in table, the individual Profits are correct but final profit (=1396.24) is wrong:
       

      on excel calculation, the profit (=569.3903😞

      company_idQty_AAvg_AAvg_BProfit
      100493.757.534091344.8636
      1012018.93.027273317.4545
      1022415.87515.2045516.09091
      1033610.666673.574468255.3191
      104409.6752.860169272.5932
      1051003.92.607692129.2308
      1061442.3958334.729167-336
      1071003.487.17-369
      108883.9886361.951531179.2653
      109448.04545516.625-377.5
      110566.3753.927273137.0727
         Final Profit569.3903
           

      could you please help me.

      amitchandak Anonymous 

      • jyaul12's avatar
        jyaul12
        Frequent Visitor

        i solved it by measures:

        Profit =sumx(values(sheet1[companyid]), [Qty_A]*([Avg_A]-[Avg_B]))