Tagged: DAX Functions
This topic contains 3 replies, has 2 voices, and was last updated by Mike Shellito 7 years, 2 months ago.
-
AuthorPosts
-
January 29, 2017 at 5:22 pm #7406
I have been trying to write function in DAX:
–> ChargerType = IF(IFERROR(FIND(“DC”,’2017-01-25_Tickets_Data'[ASSET NAME],8,”DC”,IF(IFERROR(FIND(“AC”,’2017-01-25_Tickets_Data'[ASSET NAME],8,”L2″,”checkTicket”))))))
I keep getting following error: Too many arguments were passed to the FIND function. The maximum argument count for the function is 4.
The data variable or 2017-01-25_Tickets_Data'[ASSET NAME] is: DFWT101DC1 or NCAW3005AC15 (and similar) (the DC and AC can fall in different positions.Objective is to extract the “DC” or “AC” out of the string and put in a new column. When it is “DC” then “DC”, when it is “AC” then “L2”.
Had a formula similar in excel, but obviously doesn’t work in DAX. NEED HELP!
Thanks!January 29, 2017 at 9:01 pm #7407It looks like you are missing the right parentheses on both find functions.
Where you have:
IF(IFERROR(FIND(“DC”,’2017-01-25_Tickets_Data'[ASSET NAME],8,”DC” – try
IF(IFERROR(FIND(“DC”,’2017-01-25_Tickets_Data'[ASSET NAME],8,”DC”)Where you have:
IF(IFERROR(FIND(“AC”,’2017-01-25_Tickets_Data'[ASSET NAME],8,”L2″ – try
IF(IFERROR(FIND(“AC”,’2017-01-25_Tickets_Data'[ASSET NAME],8,”L2″)January 30, 2017 at 12:50 am #7409thanks for the reply… almost there.
now i am receiving msg:Too few arguments were passed to the IF function. The minimum argument count for the function is 2.
This shouldn’t be so difficult.
tks/ 🙂January 31, 2017 at 1:51 am #7438I had noticed that you were missing the two parentheses and gave you that answer without testing it.
When I modeled the problem, I ran across a couple of things. First, you can’t use “Find” to find a string inside a column. When I found that out, I looked for another function that would work. I found “Search” and said aha, that should do it. Wrong. It should work but I get an error when I tried it (in both Excel 2016 and Power BI). I banged my head a couple of times and finally came up with the following:
IF (
MID ( ’2017-01-25_Tickets_Data'[ASSET NAME], 8, 2 ) = “DC”,
“DC”,
IF ( MID (’2017-01-25_Tickets_Data'[ASSET NAME], 9, 2 ) = “AC”, “L2”, “checkTicket” )
)
For this to work, you must know the position for the search characters, and if you have more than a few different search characters, it would become unwieldy.
If the search characters would not occur anywhere else in the search string, you could also try a Get & Transform conditional column with “contain”. -
AuthorPosts
The forum ‘Power BI’ is closed to new topics and replies.