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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
JoeDoe
Frequent Visitor

DAX to calculate Hierarchical sales by weight

Hi,

 

My sales data are from SQL database and my weight data are from Excel spreadesheet.

This is my model diagram:

asdasdasd0.jpg

Now I want to calculate my sales by weight. So I am looking for some fomular like this:

Sales/Weight

This has to be filtered by hierarchy. 

 

I tried this DAX measure:

Weight = 
VAR catW = SELECTEDVALUE(weight[catgory])

VAR deptW = SELECTEDVALUE(weight[subdept])

VAR catS = SELECTEDVALUE(CAT_TAB[categoryDesc])

VAR deptS = SELECTEDVALUE(SDP_TAB[DepartmentDesc])

RETURN

IF(catW=catS && deptW=deptS,SUMX(weight,weight[weight],0))

 

The weight only return a total aggregation of weight, it doesn't break down by hierarchy. Thus I can't use this weight to divide my sales.

 

What is my issue? Can anyone help me on this?

 

Thanks.

4 REPLIES 4
az38
Community Champion
Community Champion

Hi @JoeDoe 

Im not sure understand you correct, but maybe CALCULATE() will be enough?

like

IF(catW=catS && deptW=deptS,CALCULATE(SUMX(weight,weight[weight]),0))

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
JoeDoe
Frequent Visitor

@az38 Thanks for the adivse.

I found if I add the department and category from weight into the visulazation table, I can break down weight correctly.

I think my following question would be: is there any workaround for use my sales hierarchy to break down my weight data? 

Here is what I have now:

asdasdasd.jpg

az38
Community Champion
Community Champion

@JoeDoe
And what do you want to see as a result?

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
JoeDoe
Frequent Visitor

I am expecting use the hierarchy of weight to break down the sales OR use the hierarchy of sales to break down the weight.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.