Forum Discussion

floralau's avatar
floralau
New Member
4 years ago
Solved

Top N error: The expression refers to multiple columns.

Hi all,
 
I am new to power bi and faced some difficulties.

What's wrong with my following code?
 
measure =
TOPN(
3,
'Succesful Rate',
'Succesful Rate'[Channel],0
)
 
The error message is: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
 
 
Also, what i would like to do is to find out the number of different strings in "Channel".
"Channel" contains "aaa","aaa","aaa","bbb","bbb","ccc","ddd","ddd" etc.
 
Thanks for your help!
  • Hi floralau 

     

    Download example PBIX file with the following code

     

    TOPN returns a table which is why you are getting the error about 'multiple columns'.  I guess you are trying to create a measure, but a measure must be a single value, it can't hold a table.

     

    To count the number of different strings use this measure

     

    Number of Diff Strings = DISTINCTCOUNT('Successful Rate'[Channel])

     

     

    Regards

     

    Phil

2 Replies

  • Hi floralau 

     

    Download example PBIX file with the following code

     

    TOPN returns a table which is why you are getting the error about 'multiple columns'.  I guess you are trying to create a measure, but a measure must be a single value, it can't hold a table.

     

    To count the number of different strings use this measure

     

    Number of Diff Strings = DISTINCTCOUNT('Successful Rate'[Channel])

     

     

    Regards

     

    Phil