Forum Discussion

aravindh10's avatar
aravindh10
Icon for Helper I rankHelper I
7 years ago
Solved

% cost for a order

product nameqtyamountcost[amount/qty]cost%[cost/total cost)
a10100010033.33333
b20200020066.66667
  total300100%

my measure is

% cost per qty =
var total_cost= DIVIDE([amount],[qty])
return CALCULATE(DIVIDE(DIVIDE(SUMX(abc,[amount]),SUMX(abc,[SOLD_QTY])),cost))
 
please help me with the correct measure
  • hi, aravindh10 

    Just try this formula to create a meausre

    % cost per qty = 
    var _costytable= SUMMARIZE(abc,abc[MonthYear],"_cost1",DIVIDE([amount],[qty]))
    var _totaltable=SUMMARIZE(ALLSELECTED(abc),abc[MonthYear],"_cost2",DIVIDE([amount],[qty])) return
    DIVIDE(SUMX(_costytable,[_cost1]),SUMX(_totaltable,[_cost2]))

    Result:

    here is pbix file, please try it.

     

    Best Regards,

    Lin

     

6 Replies

  • You could use a calculated column like this:

     

    % cost per qty = cost[cost[amount/qty]]]/SUM(cost[cost[amount/qty]]])

     

    Best Regards,
    Miguel

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • aravindh10's avatar
      aravindh10
      Icon for Helper I rankHelper I

      i want measure.Only available columns are qty and amount

      • ZunzunUOC's avatar
        ZunzunUOC
        Icon for Resolver III rankResolver III

        Please, review your raw data, the second row is wrong and if cost would equal for two row.

         

        And the other hand, calculated columns are the best way to get your goal.

         

        Column cost would be:

         

        Cost = cost[amount]/cost[qty]

         

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    hi, aravindh10 

    i want measure.Only available columns are qty and amount

    Do you mean that [amount] and [qty] are column not measure

    If so, your formula is wrong in measure

    % cost per qty =
    var total_cost= DIVIDE([amount],[qty])
    return CALCULATE(DIVIDE(DIVIDE(SUMX(abc,[amount]),SUMX(abc,Hybris[SOLD_QTY])),cost))

    And what is Hybris table in the formula.

    try this formula:

    % cost per qty =
    var total_cost= DIVIDE(SUM([amount]),SUM([qty]))
    return CALCULATE(DIVIDE(DIVIDE(SUMX(abc,[amount]),SUMX(abc,Hybris[SOLD_QTY])),cost))

    If you not your case, please share some complete sample data and expected output.

     

    Best Regards,

    Lin

    • aravindh10's avatar
      aravindh10
      Icon for Helper I rankHelper I
       field is available as Measurefield is available as Measurewhat I got using the measure which i got from the communitycostcost%Required  Measure
      MonthYearAmountQty% cost per qtyAmount/Qtycost/total cost% cost per qty
      19-May$20,379,005384051.026826333530530/152534%
      19-Jun$11,952,378241420.958038303495495/152532%
      19-Apr$4,957,26896100.998207489515515/152533%
          1525 100%
      • v-lili6-msft's avatar
        v-lili6-msft
        Icon for Community Support rankCommunity Support

        hi, aravindh10 

        Just try this formula to create a meausre

        % cost per qty = 
        var _costytable= SUMMARIZE(abc,abc[MonthYear],"_cost1",DIVIDE([amount],[qty]))
        var _totaltable=SUMMARIZE(ALLSELECTED(abc),abc[MonthYear],"_cost2",DIVIDE([amount],[qty])) return
        DIVIDE(SUMX(_costytable,[_cost1]),SUMX(_totaltable,[_cost2]))

        Result:

        here is pbix file, please try it.

         

        Best Regards,

        Lin