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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
DPSir
New Member

DAX for calculate cross tables

Hello,

 

I have problems about Power BI DAX as below. Could you guys please help me?

 

I have 2 tables:

Sheet 1

Month/YesrTypeQty
10/23A10
10/23B20
11/23A20
11/23C10
12/23A30
12/23B30
01/24A40
01/24B5

 

Sheet2:

Month/YesrTypeQty
10/23A2
11/23A1
11/23C1
01/24A1
01/24B4

 

I connected model like this:

DPSir_0-1720613118245.png


What I want to calculate is (sheet 2 qty / sheet 1 qty) *100 but want to show in line chart as y-axis , x-axis is Month/year.

As example result that I want for 10/23 of A is (2/10)*100 = 20 and not show B
But in my Power BI shown (2/30)*100 = 6.67 [Power BI sum A and B together] [my DAX is MeasureSUM(Sheet2[Qty])/SUM(Sheet1[Qty])*100] as chart below

DPSir_1-1720613590909.png

 


How can I fix this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DPSir ,

I think I understand what you're trying to do, you just want to calculate about A and you don't want to bring in the value of B,

so in this case, we can use our DAX statement to add two filters to help me accomplish this.

 

SumQtySheet1 = CALCULATE(SUM(Sheet1[Qty]),FILTER('Sheet1',Sheet1[Month/Yesr]IN VALUES(Sheet2[Month/Yesr])&&'Sheet1'[Type] IN VALUES(Sheet2[Type] )))
SumQtySheet2 = CALCULATE(SUM(Sheet2[Qty]),FILTER(Sheet2,'Sheet2'[Month/Yesr]IN VALUES(Sheet1[Month/Yesr])&&Sheet2[Type] IN VALUES(Sheet1[Type]))) 
Measure = DIVIDE([SumQtySheet2],[SumQtySheet1],0) *100

 

vxingshenmsft_0-1720750754283.png

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @DPSir ,

I think I understand what you're trying to do, you just want to calculate about A and you don't want to bring in the value of B,

so in this case, we can use our DAX statement to add two filters to help me accomplish this.

 

SumQtySheet1 = CALCULATE(SUM(Sheet1[Qty]),FILTER('Sheet1',Sheet1[Month/Yesr]IN VALUES(Sheet2[Month/Yesr])&&'Sheet1'[Type] IN VALUES(Sheet2[Type] )))
SumQtySheet2 = CALCULATE(SUM(Sheet2[Qty]),FILTER(Sheet2,'Sheet2'[Month/Yesr]IN VALUES(Sheet1[Month/Yesr])&&Sheet2[Type] IN VALUES(Sheet1[Type]))) 
Measure = DIVIDE([SumQtySheet2],[SumQtySheet1],0) *100

 

vxingshenmsft_0-1720750754283.png

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

 

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

 

It's work. Thank you very much.🍻

DPSir
New Member

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.