cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
danimelv Regular Visitor
Regular Visitor

Create a column based on a measure

Hi experts,

 

Having this table (this is a portion of a huge table):

 

IdSportevent
User1Sport1Event1
User2Sport1Event2
User3Sport2Event3
User3Sport2Event4
User3Sport2Event5
USer3Sport2Event6
User4Sport3Event7
User4Sport3Event8
User5Sport2Event9
User6Sport4Event10
User6Sport4Event11
User6Sport4Event12
User6Sport4Event13
User6Sport4Event14
User6Sport4Event15
User3Sport1Event1
User3Sport1Event5

 

I want to create a table like this:

Sport1  
 QtEventsUsers
 12
 21
 30

 Sport would be the filter, and I want to get the number of users who belongs to an event. In this case, User3, belongs to 2 events [Event1, Event5]; User1 belongs to 1 event [Event1] and User2, belongs to one event [Event2].

I have an idea about what I want to do, but can't translate it to DAX.

 

 

1. Count of Id.

2. Count of rows, form the previous step.

 

with this steps, I can get something like

 

Sample.png

From this, I want to apply step 2, in this way, I think I could create the result table with. This can be read to something like, user1 and user2, belong to 1 Event; User3, belongs to 2 events.

Please see the atached file here!

 

 Any suggestion?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Create a column based on a measure

Hi @danimelv

Create a column
count of events for each user =
CALCULATE (
    DISTINCTCOUNT ( Eventos[event] ),
    FILTER (
        ALLEXCEPT ( Eventos, Eventos[Sport] ),
        Eventos[Id] = EARLIER ( Eventos[Id] )
    )
)
Create a measure
count of Users =
CALCULATE (
    DISTINCTCOUNT ( Eventos[Id] ),
    FILTER (
        ALLSELECTED ( Eventos ),
        Eventos[count of events for each user]
            = MAX ( Eventos[count of events for each user] )
    )
)
Capture7.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: Create a column based on a measure

Check this file





Did I answer your question? Mark my post as a solution!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


Super User IV
Super User IV

Re: Create a column based on a measure

The final table you want is not very clear.  Add a few tables.





Did I answer your question? Mark my post as a solution!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


danimelv Regular Visitor
Regular Visitor

Re: Create a column based on a measure

Thanks for your response @amitchandak .

 

When I select Sport1, the output table should be:

QtEventsQtUsers
12
21
30
40
50
60

 

Sport2:

QtEventsQtUsers
11
20
30
41
50
60

 

Sport3:

QtEventsQtUsers
10
21
30
40
50
60

 

Sport4: 

QtEventsQtUsers
10
20
30
40
50
61

 

Thanks

Community Support Team
Community Support Team

Re: Create a column based on a measure

Hi @danimelv

Create a column
count of events for each user =
CALCULATE (
    DISTINCTCOUNT ( Eventos[event] ),
    FILTER (
        ALLEXCEPT ( Eventos, Eventos[Sport] ),
        Eventos[Id] = EARLIER ( Eventos[Id] )
    )
)
Create a measure
count of Users =
CALCULATE (
    DISTINCTCOUNT ( Eventos[Id] ),
    FILTER (
        ALLSELECTED ( Eventos ),
        Eventos[count of events for each user]
            = MAX ( Eventos[count of events for each user] )
    )
)
Capture7.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors