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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AlexTimefire
New Member

Counting an analyzing all references in another table

I have a table CHAR_Characters
One of the fields is PlayerId, this is a unique key

I have another table Events_SI_PlayerOffline
It has a field PlayerId (Matches PlayerID from CHAR_Characters)
It also has a field for Duration,
Finally, it has a field for EventDate


They are setup in a one to many (1:*) Relationship of one CHAR_Characters to many Events_SI_PlayerOffline

I can easily chart the average Duration for each date. But if I wanted to say, get the average Duration for each date, for each PLAYER, I run into trouble.

For example, if I have an entry in CHAR_Characters for PlayerID 345
And on 1/29/2019 there are three entries in Events_SI_PlayerOffline, with Player ID 345, and following durations: 1, 1, 10

Assuming PlayerID 345 is the only PlayerID with entries in Events_SI_PlayerOffline for that day
The average Duration on that day would be 4 minutes. I can get this easily
However, the Average Duration on that day PER PLAYER would be 12 minutes, but I do not know how to currently calculate and chart that.


It should be noted I am using DirectQuery, as we have a very large, and continously expanding dataset.

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

Hi @AlexTimefire

Create measures

Measure =
CALCULATE (
    SUM ( Events_SI_PlayerOffline[Duration] ),
    ALLEXCEPT (
        Events_SI_PlayerOffline,
        Events_SI_PlayerOffline[EventDate],
        Events_SI_PlayerOffline[PlayerId]
    )
)

Measure 2 =
CALCULATE (
    DISTINCTCOUNT ( Events_SI_PlayerOffline[PlayerId] ),
    ALLEXCEPT ( Events_SI_PlayerOffline, Events_SI_PlayerOffline[EventDate] )
)


Measure 3 = [Measure]/[Measure 2]

17.png

 

Best Regards

Maggie

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @AlexTimefire

Create measures

Measure =
CALCULATE (
    SUM ( Events_SI_PlayerOffline[Duration] ),
    ALLEXCEPT (
        Events_SI_PlayerOffline,
        Events_SI_PlayerOffline[EventDate],
        Events_SI_PlayerOffline[PlayerId]
    )
)

Measure 2 =
CALCULATE (
    DISTINCTCOUNT ( Events_SI_PlayerOffline[PlayerId] ),
    ALLEXCEPT ( Events_SI_PlayerOffline, Events_SI_PlayerOffline[EventDate] )
)


Measure 3 = [Measure]/[Measure 2]

17.png

 

Best Regards

Maggie

Thanks you so much Maggie! Now I can dig down and figure out exactly how these measures work, so I can apply this kind of behavior to other tables.

Helpful resources

Announcements
Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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