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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sakshikaul
Helper III
Helper III

dax Error

Following DAX is giving me an error. Please help

 

GP Yeild KG =
var prodA=divide ( CALCULATE(Sum(DBALLSTAT[Profit])),CALCULATE(Sum(DBALLSTAT[ChglWt(KG)]),Group_Logic[Mode_group_3]="AIR"))
var prodB=Divide(CALCULATE(Sum(DBALLSTAT[Profit])),CALCULATE(Sum(DBALLSTAT[Tues]),Group_Logic[Mode_group_3]="OCEAN"))
var ProdC=divide(CALCULATE(Sum(DBALLSTAT[Profit])),CALCULATE(Sum(DBALLSTAT[ChglWt(KG)])) )

var ProdD= if([Mode_group_3]="Air",divide(prodA,prodB),Divide(ProdA,ProdC))
return ProdD

1 ACCEPTED SOLUTION

var prodA= CALCULATE(Sum(DBALLSTAT[Profit])) var ProdA1=CALCULATE(Sum(DBALLSTAT[ChglWt(KG)]))
var prodB=CALCULATE(Sum(DBALLSTAT[Profit])) var ProdB2=FLOOR(CALCULATE(sum(DBALLSTAT[Tues]) +(sum(DBALLSTAT[CBM])/25)),1)
var ProdC=CALCULATE(Sum(DBALLSTAT[Profit])) var ProdC2=CALCULATE(Sum(DBALLSTAT[ChglWt(KG)]))
var ProdD= if (SELECTEDVALUE(Group_Logic[Mode_group_1])="AIR",divide(prodA,ProdA1), if(SELECTEDVALUE(Group_Logic[Mode_group_1])="OCEAN",divide(ProdB,ProdB2),divide(ProdC,ProdC2)))

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@sakshikaul , You have to change var ProdD like this and try

var ProdD= if(max([Mode_group_3])="Air",divide(prodA,prodB),Divide(ProdA,ProdC))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

sakshikaul_0-1615911887488.png

Still getting the error

 

@sakshikaul , use SELECTEDVALUE instead max 

 

ProdD= if(SELECTEDVALUE([Mode_group_3])="Air",divide(prodA,prodB),Divide(ProdA,ProdC))

 

Regards, 

Manikumar





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Anonymous
Not applicable

Hi@sakshikaul, 

 

According to the image you provided, the highlighted section needs to be re-referenced, and not referencing the column correctly is causing this error.

Screenshot 2021-03-19 172109.png

 

Hope it helps.

 

Best Regards,
Caitlyn Yan

 

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

Hi,

I have referenced to a column name but still not getting the output . 

When I am Selecting filter Mode as AIR. I am getting the output but when selecting Mode = OCEAN then I am getting blank values

sakshikaul_0-1616254898716.png

when Filter Mode=AIR

sakshikaul_1-1616255105084.png

 

var prodA= CALCULATE(Sum(DBALLSTAT[Profit])) var ProdA1=CALCULATE(Sum(DBALLSTAT[ChglWt(KG)]))
var prodB=CALCULATE(Sum(DBALLSTAT[Profit])) var ProdB2=FLOOR(CALCULATE(sum(DBALLSTAT[Tues]) +(sum(DBALLSTAT[CBM])/25)),1)
var ProdC=CALCULATE(Sum(DBALLSTAT[Profit])) var ProdC2=CALCULATE(Sum(DBALLSTAT[ChglWt(KG)]))
var ProdD= if (SELECTEDVALUE(Group_Logic[Mode_group_1])="AIR",divide(prodA,ProdA1), if(SELECTEDVALUE(Group_Logic[Mode_group_1])="OCEAN",divide(ProdB,ProdB2),divide(ProdC,ProdC2)))

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors