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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
AdaL02
Frequent Visitor

How to calculate number of users performing n number of users with criteria applied

HI all, I'm new to PowerBi. I had a similar post couple of days ago but I need new tweak.

 

I want to calculate number of users who performed 1 action, 2 actions, 3 etc.. but now, I only want to count number of actions after the user performed "open" action.

for example, in the dataset below, Adrian theoratically did 4 actions. However, to my analysis, he did only 2 actions. Message sent is going to apply to everyone, and I only want to count actions after there is open.

 

user name     actions     action value

Adrian            call             30%

Adrian           video          click

Adrian           open          open

Adrian          Message        sent

Bob              open           open

Bob           Message         sent

Charlie       Message        sent

Charlie        open            open

Charlie       video             click

Daniel      message          sent

 

and therefore, based on new context, my final results should be like this:

#actions          #users

0                          1 (Bob, didn't do anything after open)

1                          1 (Charlie, clicked video after open)

2                          1 (Adrian, called and clicked video)

Daniel will not be counted because he never opened the message.

 

Thanks to share your guidance!

cheers,

Ada

 

my earlier question on the same topic, though without this tweak required is here 

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @AdaL02 ,

 

As you description, the output based on your sample data should be :

#actions          #users

0                          1

1                          0

2                          3

 

And you can try the following method. Create an index column in your sample data:

 

Capture.PNG

 

Then you can create a new calculated table:

 

Table2 =
ADDCOLUMNS (
    SELECTCOLUMNS ( { 0, 1, 2 }, "#actions", [Value] ),
    "#users",
        CALCULATE (
            COUNT ( 'Table'[user name] ),
            FILTER (
                VALUES ( 'Table'[user name] ),
                VAR a =
                    CALCULATE ( MAX ( 'Table'[Index] ), 'Table'[actions] = "open" )
                VAR b =
                    MAX ( 'Table'[Index] )
                RETURN
                    IF ( ISBLANK ( a ), 0, b - a ) = [#actions]
            )
        ) + 0
)

 

Capture1.PNG

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hi @AdaL02 ,

 

As you description, the output based on your sample data should be :

#actions          #users

0                          1

1                          0

2                          3

 

And you can try the following method. Create an index column in your sample data:

 

Capture.PNG

 

Then you can create a new calculated table:

 

Table2 =
ADDCOLUMNS (
    SELECTCOLUMNS ( { 0, 1, 2 }, "#actions", [Value] ),
    "#users",
        CALCULATE (
            COUNT ( 'Table'[user name] ),
            FILTER (
                VALUES ( 'Table'[user name] ),
                VAR a =
                    CALCULATE ( MAX ( 'Table'[Index] ), 'Table'[actions] = "open" )
                VAR b =
                    MAX ( 'Table'[Index] )
                RETURN
                    IF ( ISBLANK ( a ), 0, b - a ) = [#actions]
            )
        ) + 0
)

 

Capture1.PNG

 

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

 

Best Regards,

Dedmon Dai

Tahreem24
Super User
Super User

@AdaL02  try this measure:

Measure = CALCULATE(COUNT('TableName'[UserName]),'TableName'[Action] in {"Video","Call"})
 
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
amitchandak
Super User
Super User

@AdaL02 , Add an index column and try a measure like

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

 

Measure =
VAR __id = MAX ('Table'[user name] )
VAR __date = CALCULATE ( MAX('Table'[Index] ), ALLSELECTED ('Table' ), 'Table'[user name] = __id && 'Table'[action value] = "Open")
CALCULATE ( Count ('Table'[user name] ), VALUES ('Table'[user name] ),'Table'[user name] = __id,'Table'[Index] >= __date )

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.