Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

DAX error in IF statement

Can someone instruct me how to get rid of this DAX error. A single value for column 'dmc_name' in table 'dmc' cannot be determined. This can happen when a measure formula refers to a column that contains many values .

 

Name = if ('dmc'[dmc_name] = "AURORA" , "b","a")
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,
    Based on the description provided, it looks like you are encountering an issue where the IF statement in your DAX expression is expecting a single value for the 'dmc_name' column but is instead getting multiple values. This typically happens in a row context where the column reference is ambiguous.
    You can use the selectedvalue function in your original formulas to specify the value you choose to match the logic of the judgment.

    Here is my test data:

    Crate a measure

     

    Name = IF(SELECTEDVALUE(dmc[dmc_name]) = "AURORA","b","a")

     

    FInal output

     

    Best regards

    Albert He

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
     

     

     

6 Replies

  •  , Try this one 

    Name = IF(MAX('dmc'[dmc_name]) = "AURORA", "b", "a")

     

    And accept as solution if it helps

    Anonymous

    • Anonymous's avatar
      Anonymous
      Not applicable

      No, The Max function only looks at the greatest dmc_name value in the table and I need to inspect every occurance of the dmc_name. Can I use some other function like Filter or Calculate or a grouping function inside the If statement or inplace of it? 

      • Daniel29195's avatar
        Daniel29195
        Community Champion

        hello Anonymous ,

         

        can you please provide the pbix file so i can take a look and try to help you with the solution ? 

        if you cant ,  could you at least share screenshots about the sample data and the output desired  ? 

         

        best regards

  • Yes you can use filter function in this way

     

    Name =
    IF(
    COUNTROWS(FILTER('dmc', 'dmc'[dmc_name] = "AURORA")) > 0,
    "b",
    "a"
    )

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,
    Based on the description provided, it looks like you are encountering an issue where the IF statement in your DAX expression is expecting a single value for the 'dmc_name' column but is instead getting multiple values. This typically happens in a row context where the column reference is ambiguous.
    You can use the selectedvalue function in your original formulas to specify the value you choose to match the logic of the judgment.

    Here is my test data:

    Crate a measure

     

    Name = IF(SELECTEDVALUE(dmc[dmc_name]) = "AURORA","b","a")

     

    FInal output

     

    Best regards

    Albert He

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly