Forum Discussion

walt20221's avatar
walt20221
Frequent Visitor
4 years ago

Minus operator not working for my formula

Good Day Team,

I am testing the water with power bi and DAX and I think I got stuck in a little problem while putting my formula, so will be great if you can give me your feedbacks.

 

Here is my problem, I did create a measure to calculate:

1- REVENUE PER MOVEMENT wich is a division and the calculation is based on a condition.

2- also COST PER MOVEMENT which is a divisionand the calculation is based on a condition.

The statement 1 and 2 avobe are being calculated with the following statement and it works.

 

Base Measure =
IF(
HASONEVALUE(MainTable[Description]),
IF(
VALUES(MainTable[Description]) = "3) TOTAL REVENUE PER TEU",
DIVIDE(
CALCULATE(SUM(MainTable[Amt]), MainTable[Description] = "1) REVENUE BASE SLOTS" ),
CALCULATE(SUM(MainTable[Amt]), MainTable[Description] = "2) TOTAL TEUS" )
), IF( values(MainTable[Description]) = "4) COST PER TEU", DIVIDE(CALCULATE(SUM(MainTable[Amt]), MainTable[Description] = "1) TOTAL COSTS"), CALCULATE(SUM(MainTable[Amt]), MainTable[Description] = "2) TOTAL TEUS") ),
 
SUM(MainTable[Amt])))
 
Also I want to calculate the MARGIN and this is a challenge because is a substraction but my condition is not working, so not sure how to use the minus (-)
 

VALUES(MainTable[Description]) = "1) MARGIN PER TEU",                                                           CALCULATE(SUM(MainTable[Amt]), MainTable[Description] = "3) TOTAL REVENUE PER TEU") -                                  CALCULATE(SUM(MainTable[Amt]), MainTable[Description] = "4) COST PER TEU"),

  

Thanks

 

 

1 Reply

  • I'm not sure what's happening but my best guess is that this is an auto-exists issue that could be resolved by using a dimension table for [Description].

     

    For better help, please share some example data and a comparison of what you're currently seeing versus what you expect to see. Sharing a link to a copy of an example pbix you've uploaded to a cloud service like DropBox/GoogleDrive/SharePoint would be ideal.