Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Ignoring Filter and calculating count

Hi Everyone,

I have a requirement to caluclate distinct "ID's" which are having comments and having comments=blanks() for each user.

I have created two measures to caluclate count of ID's for individual users.

Completed = var av=  CALCULATE(DISTINCTCOUNT('Table'[ID]),'Table'[Comment]<>BLANK())

                                    return   IF(av=BLANK(),0,av)
Incompleted = var ac=  CALCULATE(DISTINCTCOUNT('Table'[ID]),'Table'[Comment]=BLANK())
                                    return   IF(ac=BLANK(),0,ac)
 

 How to look the ID's which are having comments in prev rows. 

 

 

 

Expected result "0" instead of "2", since for user a products 1&2 having comments in prev dates

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous  ,

    I created a sample pbix file(see attachment) for you, please check whether that is what you want.

    1. Create a calculated column as below:

    Maxdate = 
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            'Table',
            'Table'[User] = EARLIER ( 'Table'[User] )
                && 'Table'[ID] = EARLIER ( 'Table'[ID] )
        )
    )

    2. Create two measures to get the count of completed and incompleted IDs

    Completed = 
    VAR _count =
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[ID] ),
            FILTER (
                'Table',
                'Table'[Date] = 'Table'[Maxdate]
                    && 'Table'[Comment] <> BLANK ()
            )
        )
    RETURN
        _count + 0
    Incompleted = 
    VAR _count =
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[ID] ),
            FILTER (
                'Table',
                'Table'[Date] = 'Table'[Maxdate]
                    && 'Table'[Comment] = BLANK ()
            )
        )
    RETURN
        _count + 0

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

2 Replies

  • Hi there!

    You could try:
    CALCULATE( COUNTROW( 'Table' ), 'Table'[Comment] <> BLANK() )

    Let me know if that helps!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous  ,

    I created a sample pbix file(see attachment) for you, please check whether that is what you want.

    1. Create a calculated column as below:

    Maxdate = 
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            'Table',
            'Table'[User] = EARLIER ( 'Table'[User] )
                && 'Table'[ID] = EARLIER ( 'Table'[ID] )
        )
    )

    2. Create two measures to get the count of completed and incompleted IDs

    Completed = 
    VAR _count =
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[ID] ),
            FILTER (
                'Table',
                'Table'[Date] = 'Table'[Maxdate]
                    && 'Table'[Comment] <> BLANK ()
            )
        )
    RETURN
        _count + 0
    Incompleted = 
    VAR _count =
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[ID] ),
            FILTER (
                'Table',
                'Table'[Date] = 'Table'[Maxdate]
                    && 'Table'[Comment] = BLANK ()
            )
        )
    RETURN
        _count + 0

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards