Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Milan14
Frequent Visitor

Distinct Count of User based on conditions

Hello everyone,

 

I would like to have a distinct count of USERID as at end month from date slicer, selected YEAR = 2021 and MONTH = February, include all the users who fulfil these two conditions.


Condition 1: User who registered before the end of February 2021 under ACCOUNT = AAA.
Condition 2: User who performed a transaction with ACCOUNT = BBB before the end of February 2021.


User who fulfils either one condition (condition 1 / condition 2) also will be counted. User will count as 1 user instead of 2 users if the user fulfils both conditions.


Sample table:

Milan14_2-1631697278658.png

 

Expected outcome in table:

Milan14_3-1631697312050.png

 

Expected outcome in card:

Total user

3

 

Thank you

 

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi,

You can create this column:

No. of User =
VAR end_of_february =
    ENDOFMONTH ( DATE ( 2021, 2, 1 ) )
RETURN
    IF (
        OR (
            AND ( [ACCOUNT] = "AAA", [REGISTERED DATE] <= end_of_february ),
            AND ( [ACCOUNT] = "BBB", [TRANSACTION DATE] <= end_of_february )
        ),
        1,
        0
    )

 

It will give you the outcome you expect. Summing this column you can get total users.

Regards,

Marc

Hi @Anonymous ,

 

Thanks for your help. I have tried out with the formula you suggested but it does not fully achieve my requirement. I have created a measure instead of a column with the formula you suggested and it's work !

 

This is the measure I created:

 

No. of user = 

VAR LastSelectedDate = CALCULATE(MAX('Calander'[Date]))

RETURN

CALCULATE(DISTINCTCOUNT('Table'[USERID]), IF(OR('Table'[Transaction Date] < LastSelectedDate && 'Table'[ACCOUNT] = "BBB", 'Table'[Regsitered Date] < LastSelectedDate && 'Table'[ACCOUNT] = "AAA"), 1, 0))

 

Milan

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.