A table of multiple values was supplied where a single value was expected, when using Distinct

Caaarlos picture Caaarlos · Feb 24, 2017 · Viewed 27.3k times · Source

I have the following table:

enter image description here

I'm trying to create a new column using Dax language:

Column = DISTINCT('Edição'[País])

But I gott this error message:

A table of multiple values was supplied where a single value was expected.

The expected result is:

enter ription here

Answer

Jeroen picture Jeroen · Feb 25, 2017

You have a source table with 21 rows. You want to add a column. In the end you'll still have 21 rows.

The "expected" table has 18 rows. So with only adding a column you will never get there, it's just impossible.

To get the expected output though, you can do this easily: just create a table with just Pais as values and PowerBI will automatically group. See here a (more minimal) example:

Example grouped table

PS. If you wanted to add a column -say- with the number of years the country appears in the source data, you should:

  • choose the matrix visualization
  • add "Pais" (country) for rows
  • add e.g. "Ano" (year) for values, and summarize by "Count (Distinct)"