Forum Discussion

syafeeq's avatar
syafeeq
New Member
2 years ago
Solved

COUNT in new column

I am new with PowerBI 

 

I would like to count the number of item_code and put it in a new colum. 

 

 

so the new column will have

item_code 1 = 3

item_code x = 2

item_code y = 1

etc

How can i do that? 

 

thanks

  • do you mean by year?

     

    calculate(count(item),allexcept(table, year))

     

    if you want distinct count ,try this

    calculate(distinctcount(item),allexcept(table,year)

  • syafeeq's avatar
    syafeeq
    2 years ago

    I tried the following & it works for my need

    CALCULATE(
    COUNT(_TempTable[item_code]),
    ALLEXCEPT(_TempTable,_TempTable[item_code])
    )

    thanks for the tip

3 Replies

  • do you mean by year?

     

    calculate(count(item),allexcept(table, year))

     

    if you want distinct count ,try this

    calculate(distinctcount(item),allexcept(table,year)

    • syafeeq's avatar
      syafeeq
      New Member

      I tried the following & it works for my need

      CALCULATE(
      COUNT(_TempTable[item_code]),
      ALLEXCEPT(_TempTable,_TempTable[item_code])
      )

      thanks for the tip