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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.