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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX FUNCTION

I have a formula from excel and it really works and produces the output needed. However I need to convert this formula into Dax and use it in PowerBI. I have tried both || and && and its still not working: Here is the excel formula==>

=IF(OR(AND(OBJECT="6265",VALUE(ORG)<“699”),OBJECT="6255",AND(OBJECT="6256",VALUE(ORG)<“699”),OBJECT="6257",OBJECT="6258",OBJECT="6259",OBJECT="8911",AND(OBJECT="6112",VALUE(ORG)<“699”),AND(SUB_OBJECT="XH",VALUE(ORG)<>“816”),SUB_OBJECT="LQ",AND(SUB_OBJECT="DF",VALUE(ORG)<>”961”),AND(SUB_OBJECT="TE",VALUE(ORG)<>“816”),AND(SUB_OBJECT="JF",VALUE(ORG)<“699”),AND(SUB_OBJECT="JP",VALUE(ORG)<“699”),AND(SUB_OBJECT="CM",VALUE(ORG)<>“816”),AND(SUB_OBJECT="48",VALUE(ORG)<>“969”),OBJECT="6116",OBJECT="6119",OBJECT="6129",OBJECT="6141",OBJECT="6142",OBJECT="6143",OBJECT="6145",OBJECT="6146",OBJECT="6149",OBJECT="6144",OBJECT="6113",OBJECT="6126",VALUE(ORG)>“983”,AND(FUNCTION="12",VALUE(ORG)<“699”)),"NON","CON")

 

 

Note - All the the numbers here are text formats.

Thanks.

 

2 ACCEPTED SOLUTIONS

Hi @Anonymous,

You use the VALUE function, which converts a text string that represents a number to a number. For example, VALUE("3") returns number 3.  What's the type of ORG column? It is text like "32", then VALUE(ORG) returns number type, which is nou used to compare with text type, like VALUE(ORG)<“699”. Mybe you can change it to VALUE(ORG)<VALUE(“699”), and also mix corresponding arguments in @KHorseman posted formula using similar way. Please try and check if it work fine.

Best Regards,
Angelia

View solution in original post

You need to indent and format your code so you can read it. You have the wrong number of parentheses in the wrong places.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

12 REPLIES 12
KHorseman
Community Champion
Community Champion

Is this a column or a measure? Is Object a column? Org? Function? What exactly do you mean "it's not working"? What output are you getting? What output are you expecting?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Sorry these are all columns (object, org, function, sub_object). I m trying to create a now column from that formula. It create a new column in excel perfectly but not in PowerBI or DAX

Your first OR function seems to have about a dozen arguments when it is supposed to only have 2, so I assume you're just getting an error message?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Actually, it has 30 arguments. I've formatted your code so it's readable.

 

=IF(
	OR(
		AND(
			OBJECT="6265",
			VALUE(ORG)<“699”
		),
		OBJECT="6255",
		AND(
			OBJECT="6256",
			VALUE(ORG)<“699”
		),
		OBJECT="6257",
		OBJECT="6258",
		OBJECT="6259",
		OBJECT="8911",
		AND(
			OBJECT="6112",
			VALUE(ORG)<“699”
		),
		AND(
			SUB_OBJECT="XH",
			VALUE(ORG)<>“816”
		),
		SUB_OBJECT="LQ",
		AND(
			SUB_OBJECT="DF",
			VALUE(ORG)<>”961”
		),
		AND(
			SUB_OBJECT="TE",
			VALUE(ORG)<>“816”
		),
		AND(
			SUB_OBJECT="JF",
			VALUE(ORG)<“699”
		),
		AND(
			SUB_OBJECT="JP",
			VALUE(ORG)<“699”
		),
		AND(
			SUB_OBJECT="CM",
			VALUE(ORG)<>“816”
		),
		AND(
			SUB_OBJECT="48",
			VALUE(ORG)<>“969”
		),
		OBJECT="6116",
		OBJECT="6119",
		OBJECT="6129",
		OBJECT="6141",
		OBJECT="6142",
		OBJECT="6143",
		OBJECT="6145",
		OBJECT="6146",
		OBJECT="6149",
		OBJECT="6144",
		OBJECT="6113",
		OBJECT="6126",
		VALUE(ORG)>“983”,
		AND(
			FUNCTION="12",
			VALUE(ORG)<“699”
		)
	),
	"NON",
	"CON"
)

Columns should be referred to in square brackets, by the way. TableName[Object] for instance.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

I refered the columns by their name instance and still got the error mesage that too many arguments were passed to the VALUE function. The maximun argument count for the function is 1.

You need to indent and format your code so you can read it. You have the wrong number of parentheses in the wrong places.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Anonymous,

You use the VALUE function, which converts a text string that represents a number to a number. For example, VALUE("3") returns number 3.  What's the type of ORG column? It is text like "32", then VALUE(ORG) returns number type, which is nou used to compare with text type, like VALUE(ORG)<“699”. Mybe you can change it to VALUE(ORG)<VALUE(“699”), and also mix corresponding arguments in @KHorseman posted formula using similar way. Please try and check if it work fine.

Best Regards,
Angelia

You need to be specific about what you mean by "not working". Are you getting an error message? What error message?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Your formula should follow a pattern like

 

=IF(
	AND(
		TableName[OBJECT] = "6265",
		VALUE(TableName[ORG])<“699”
	) ||
	TableName[OBJECT]="6255" ||
	AND(
		TableName[OBJECT]="6256",
		VALUE(TableName[ORG])<“699”
	) ||

.... etc etc 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Here is the error message:

 

Capture.JPG

Anonymous
Not applicable

The error message was about the number of acceptable arguments- saying it only accepts 2

Anonymous
Not applicable

Yes I get that error message but what if I want to use multiple arguments outside of excel? I read from another forum about combining  arguments with either && or || but its still not working.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.