Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
aravindh10
Helper I
Helper I

% 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
1 ACCEPTED SOLUTION

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:

7.JPG

here is pbix file, please try it.

 

Best Regards,

Lin

 

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

View solution in original post

6 REPLIES 6
v-lili6-msft
Community Support
Community 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

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

 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%

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:

7.JPG

here is pbix file, please try it.

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ZunzunUOC
Resolver III
Resolver III

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.

i want measure.Only available columns are qty and amount

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]

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.