Home Forums Power BI Need help with DAX

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Mike Shellito 7 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7406

    cs566
    Participant
    • Started: 1
    • Replies: 1
    • Total: 2

    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!

    #7407

    Mike Shellito
    Participant
    • Started: 0
    • Replies: 2
    • Total: 2

    It 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″)

     

    #7409

    cs566
    Participant
    • Started: 1
    • Replies: 1
    • Total: 2

    thanks 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/ 🙂

    #7438

    Mike Shellito
    Participant
    • Started: 0
    • Replies: 2
    • Total: 2

    I 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”.

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘Power BI’ is closed to new topics and replies.