Forum Discussion

Gopinath_iyer's avatar
Gopinath_iyer
Helper II
4 years ago
Solved

Calculated column

Hello Friends,

 

Can you help me with the below calculation, 

I want to create a new column "B" based on existing column "A".

 

AB
Desktop4
Desktop4
Desktop4
Desktop4
Laptop2
Laptop2
IPAD3
IPAD3
IPAD3
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Gopinath_iyer ,

     

    It seems that you want to calculate the row count of each A and each Country, right?

    Please try:

    B = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[A],'Table'[Country]))

     

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

5 Replies

  • Hi, Gopinath_iyer 
    Can you be more precise about what exactly you want?
    Do you want just a duplicate of the A column? 
    You can do that by just referencing the column in Calculated Column like this:

    B = 'Table'[A]
    • Gopinath_iyer's avatar
      Gopinath_iyer
      Helper II

      I want to create column B with count of attributes in column A respectively.

      E.g Column A has 4 rows with "Desktop" so column B should 4 and 

      Column A has 2 rows for "Laptop" so B should be 2 and so on.

      • vojtechsima's avatar
        vojtechsima
        Super User

        Gopinath_iyer 
        I see, makes sense.
        Here you go:

        New B = 
        var currentGrouop = 'Table'[A]
        return COUNTROWS(FILTER('Table', 'Table'[A] = currentGrouop))
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Gopinath_iyer ,

     

    It seems that you want to calculate the row count of each A and each Country, right?

    Please try:

    B = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[A],'Table'[Country]))

     

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