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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
91asma2
Helper I
Helper I

count of distinct two columns in one table

Hi all, 
I am trying to calculation the unique number of users who did 2 or more activities from two separate columns in one table. 
My data looks like this: 

 

Table  

 

user_idactivity_id
1aa
2aa2
3aa3
4aa4
5aa5


First I want to get the distinct count of users and then filter those users that have done 2 or more activities.
I am trying something like this, but I am not getting the values right. 

VAR allData =
ADDCOLUMNS(
VALUES(Table[activity_id]),
"rowCount",
CALCULATE( COUNTROWS( Table) )
)
return
CALCULATE(
COUNTROWS( allData ),
filter (allData, [rowCount] >=7)
)

 

 

I appreciate all the help. 

2 REPLIES 2
amitchandak
Super User
Super User

@91asma2 , Try a measure like

 

countx(filter(summarize(Table, Table[user_id], "_1", count(Table[activity_id])),[_1]>=2),[user_id])

Thanks a lot @amitchandak !
Can you explain to me this forumla, more walk me thought it? 


I am trying to validate the values. and I am trying to change the filter from 2 to 1 to 3 ...etc but the number doesnt change. 

so I am not sure its counting the right values. 


What I am trying to get the count of users who has 2 or more activities. 

 

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.