Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
3 years ago
Solved

Count having 2 restrictions

Hello everyone

I wanted to ask them for help with two questions for the following data:

QUESTION 1: I have to count how many times a fruit was sold, as long as the customer has used the tool during the purchase. To know if the customer used the tool during the purchase will appear the word Ipad in any of the 4 rows corresponding to the customer, for example the Clientre1 used the ipad and also bought 2 fruits, while the client 2 did not use the ipad so his purchase will not be conciderarĂ¡ no matter how much he has bought. and the idea would be to show me the following

QUESTION 2: In line with the previous question, I need to calculate how many people bought 0,1, 2, 3 or 4 Frutras using the tool, For example client 1 bought 2 fruits, client 2 bought 2 fruits but did not use the tool so he is not conciderado, client 3 bought 3 fruits, client 4 bought 0 fruits and client 5 bought 2 fruits. then I need a table that looks like this.

Thank you very much in advance!

  • Hi, Syndicate_Admin 

     

    You can try the following methods.

    Column:

    Column =
    CALCULATE (
        MAX ( 'Table'[Herramiena] ),
        FILTER ( 'Table', [ID] = EARLIER ( 'Table'[ID] ) )
    )
    

    Measure:

    Measure = 
    CALCULATE (
        COUNT ( 'Table'[Producto] ),
        FILTER (
            ALL ( 'Table' ),
            [Column] <> BLANK ()
                && [Producto] = SELECTEDVALUE ( 'Table'[Producto] )
        )
    )

     

    Create a new table and add the Index column.
    Table 2:

    Measure:

    Count Cliente =
    CALCULATE (
        COUNT ( 'Table'[Producto] ),
        FILTER (
            ALL ( 'Table' ),
            [ID] = SELECTEDVALUE ( 'Table'[ID] )
                && [Producto] <> BLANK ()
        )
    )
    

    Column:

    Result = 
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            [Count Cliente] = EARLIER ( 'Table  2'[Index] )
                && [Column] <> BLANK ()
        )
    ) + 0

     

    Best Regards,

    Community Support Team _Charlotte

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

     

2 Replies

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi, Syndicate_Admin 

     

    You can try the following methods.

    Column:

    Column =
    CALCULATE (
        MAX ( 'Table'[Herramiena] ),
        FILTER ( 'Table', [ID] = EARLIER ( 'Table'[ID] ) )
    )
    

    Measure:

    Measure = 
    CALCULATE (
        COUNT ( 'Table'[Producto] ),
        FILTER (
            ALL ( 'Table' ),
            [Column] <> BLANK ()
                && [Producto] = SELECTEDVALUE ( 'Table'[Producto] )
        )
    )

     

    Create a new table and add the Index column.
    Table 2:

    Measure:

    Count Cliente =
    CALCULATE (
        COUNT ( 'Table'[Producto] ),
        FILTER (
            ALL ( 'Table' ),
            [ID] = SELECTEDVALUE ( 'Table'[ID] )
                && [Producto] <> BLANK ()
        )
    )
    

    Column:

    Result = 
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            [Count Cliente] = EARLIER ( 'Table  2'[Index] )
                && [Column] <> BLANK ()
        )
    ) + 0

     

    Best Regards,

    Community Support Team _Charlotte

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