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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

Hi @Anonymous

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
amitchandak
Super User
Super User

Check this file

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

Anonymous
Not applicable

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

Hi @Anonymous

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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