Forum Discussion

poweruser55's avatar
poweruser55
Helper IV
4 years ago

Count with calculated column

I created a calculated column in the Power BI query editor but I keep getting an error of token eof expected at the flag_inc. Why is this happening? I am trying to count how many "Y" are in column inc in Table 1.

var flag_inc=
CALCULATE(
COUNT('Table 1'[inc]),
ALL('Table 1'),'Table 1'[inc]="Y")

4 Replies

  • Hi,

    That should be written as a measure in your visual (not in the Query Editor).

    • poweruser55's avatar
      poweruser55
      Helper IV

      Doesn't this need to be a calculated column? I have to count for multiple columns then divide by another count of columns Ashish_Mathur 

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        I can help further only when i have some data to work with.  Also, show me the expected result.

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi poweruser55 

     

    What is your expected result? Your formula is DAX code which is not used in Power Query. You can use it to create a new column in data model, then you will have below result. Is this what you are after? 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.