Forum Discussion

Alex_ds's avatar
Alex_ds
Frequent Visitor
6 years ago
Solved

count under text column in a table

Hello Everybody,

 

An easy question, how can I add count under a text column in a table? 

 Thanks so much¡

  • Hi Alex_ds ,

     

    Maybe we can create an index column to work around instead of using the Product.

    Index = CALCULATE(DISTINCTCOUNT('Table'[Product]),FILTER('Table','Table'[Product] <= EARLIER('Table'[Product])))

     

    Then we can update the measure as below and work it out.

    Measure = 
    VAR pro =
        MAX ( 'Table'[Product] )
    RETURN
        IF ( ISFILTERED ( 'Table'[Index] ), pro, COUNT ( 'Table'[Product] ) )
    

     

    Pbix as attached.

     

     

     

4 Replies

  • AilleryO's avatar
    AilleryO
    Icon for Memorable Member rankMemorable Member

    Hi,

     

    My first thought is make a measure :

    Number Of Producto = COUNTA([Producto])

    But to display it only on the bottom line of your table is another question, may be just two tables with superposition ?

    Hope it helps

     

    Olivier

  • v-frfei-msft's avatar
    v-frfei-msft
    Icon for Community Support rankCommunity Support

    Hi Alex_ds ,

     

    We can create a measure as below to work around.

    Measure = 
    VAR pro =
        MAX ( 'Table'[Product] )
    RETURN
        IF ( ISFILTERED ( 'Table'[Product] ), pro, COUNT ( 'Table'[Product] ) )
    

     

    For more details, please check the pbix as attached.

     

    • Alex_ds's avatar
      Alex_ds
      Frequent Visitor

      Hi v-frfei-msft,

      It works correctly, thanks so much¡

      Anyway, it just works if column "Product" is in the Table. Is there any chance it works if column "Product" is not in the table?

       

      Grettings,

       

      Alex

      • v-frfei-msft's avatar
        v-frfei-msft
        Icon for Community Support rankCommunity Support

        Hi Alex_ds ,

         

        Maybe we can create an index column to work around instead of using the Product.

        Index = CALCULATE(DISTINCTCOUNT('Table'[Product]),FILTER('Table','Table'[Product] <= EARLIER('Table'[Product])))

         

        Then we can update the measure as below and work it out.

        Measure = 
        VAR pro =
            MAX ( 'Table'[Product] )
        RETURN
            IF ( ISFILTERED ( 'Table'[Index] ), pro, COUNT ( 'Table'[Product] ) )
        

         

        Pbix as attached.