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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ANB_13
Helper I
Helper I

Help Excel formula to Dax

Hello everyone, 

 

Please, someone can help me to covert this excel formula to DAX ?

 

"=IF(OR([@[NATURE CODE 1]]="A",[ @[NATURE CODE 1]]="W");([@[%VOL. CN1]]/100)*[@[GROSS MASS (kg)]];0)+SI(OU([@[NATURE CODE 2]]="A";[ @[NATURE CODE 2]]="W");([@[%Vol. CN2]]/100)*[@[GROSS MASS (kg)]];0)"

 

Thank you very much 

Regards

1 ACCEPTED SOLUTION
rubayatyasmin
Super User
Super User

Hi, @ANB_13 

 

try this one:

 

= IF(
OR(
TableName[NATURE CODE 1] = "A",
TableName[NATURE CODE 1] = "W"
),
(TableName[%VOL. CN1] / 100) * TableName[GROSS MASS (kg)],
0
) + IF(
OR(
TableName[NATURE CODE 2] = "A",
TableName[NATURE CODE 2] = "W"
),
(TableName[%Vol. CN2] / 100) * TableName[GROSS MASS (kg)],
0
)

 

replace the table with your appropriate table name. 

 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


View solution in original post

3 REPLIES 3
ANB_13
Helper I
Helper I

Hello, 

Thank you very much, 

 

I want it also in M language. Can ou help me please ?

 

Thank you very much

sure, 

 

let
Source = TableName,
DAXFormula = (Table as table) =>
let
Result1 = if List.Contains({"A", "W"}, Table[NATURE CODE 1]) then (Table[%VOL. CN1] / 100) * Table[GROSS MASS (kg)] else 0,
Result2 = if List.Contains({"A", "W"}, Table[NATURE CODE 2]) then (Table[%Vol. CN2] / 100) * Table[GROSS MASS (kg)] else 0,
FinalResult = Result1 + Result2
in
FinalResult,
CustomColumn = Table.AddColumn(Source, "Converted", each DAXFormula(_))
in
CustomColumn

 

 

if my assistance helped you in any way. hit 👍

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


rubayatyasmin
Super User
Super User

Hi, @ANB_13 

 

try this one:

 

= IF(
OR(
TableName[NATURE CODE 1] = "A",
TableName[NATURE CODE 1] = "W"
),
(TableName[%VOL. CN1] / 100) * TableName[GROSS MASS (kg)],
0
) + IF(
OR(
TableName[NATURE CODE 2] = "A",
TableName[NATURE CODE 2] = "W"
),
(TableName[%Vol. CN2] / 100) * TableName[GROSS MASS (kg)],
0
)

 

replace the table with your appropriate table name. 

 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors