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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
alfordtp
Frequent Visitor

Divide two columns throughout hierarchy

This seems like the most basic thing, but I keep running into it and am fairly new to DAX and Power BI.

 

I have the following structure.  The hierarchy has Toy > Shape > Color.  I'm trying to calculate the Unit Cost column, whether I drill down to the shape or color or whatever level.  This shouldnt be difficult and have tried "All Selected" but maybe I'm not using it correctly.  Help is appreciated, and thanks for going easy on this NewB.

 

CategoryDescriptionQtyCostUnit Cost
ToyBlocks1522414.9
  Shape  Rectangle1018018.0
    Color    Red6203.3
    Color    Green4153.8
  Shape  Triangle5448.8
    Color    Purple2105.0
    Color    Green382.7

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Assuming Cost and Quantity are measures, try this measure

Unit Cost = [Cost]/[Qty]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @alfordtp ,

Have you solved your problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please share your desired output so that we could help further on it.

Best  Regards,

Cherry

 

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

Hi,

Assuming Cost and Quantity are measures, try this measure

Unit Cost = [Cost]/[Qty]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
alexvc
Resolver I
Resolver I

I guess you are trying to calculate avg cost? If that is true, first you can try creating a column in your table called "Total Cost", this would have to be Qty * Cost. Then your Unit Cost would be a calculated measure: Unit Cost = sum("Total Cost")/sum(Qty)

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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