Forum Discussion

tom-lenzmeier's avatar
tom-lenzmeier
Helper II
4 months ago
Solved

Getting Totals On Each Row

Hello,

 

I have a basic table visual that has the following columns: Location, event date, presentation title, and attendees. I'm trying to calculate the average number of attendees by location. The numerator is the the total number of attendees for each presenation. The denominator is the total number of events for the location. The requestor wants to see the average on each row. I've tried variations on ALLEXCEPT() to no avail. Here's some sample data. There is an events table, an attendee table, and a presentation table in a star schema.

 

LocationEvent DatePresentation TitleAttendees 
Location 14/1/2026Build a Widget55
Location 14/1/2026Build a Thingy44
Location 14/3/2026Reinvent the Wheel33
Location 14/3/2026Square Peg In a Round Hole22
Location 24/10/2026Widget Strategy66
Location 24/10/2026Widget Chaos33
Location 24/12/2026Install Thingys55
Counts5 events7 Presentations28 attendees 

 

Location 1 had 2 events, 4 presentations, and 14 attendees. The average for the location is 7 (14/2)

Location 2 had 3 events, 4 presentations, and 14 attendess. The average is 4.7 (14/3)

 

The average value of 7 for location 1 needs to be on each row. Similarly, the average of 4.7 for location 2 needs to be on each row.

 

Thanks in advance!

  • Please try the measure below:

    Avg Attendees per Event =
    VAR _TotalAttendees =
        CALCULATE (
            SUM ( Events[Attendees] ),
            REMOVEFILTERS ( Presentations[PresentationTitle] ),
            REMOVEFILTERS ( Events[EventDate] )
        )
    VAR _EventCount =
        CALCULATE (
            DISTINCTCOUNT ( Events[EventID] ),
            REMOVEFILTERS ( Presentations[PresentationTitle] )
        )
    RETURN
        DIVIDE ( _TotalAttendees, _EventCount )

8 Replies

  • Please try the measure below:

    Avg Attendees per Event =
    VAR _TotalAttendees =
        CALCULATE (
            SUM ( Events[Attendees] ),
            REMOVEFILTERS ( Presentations[PresentationTitle] ),
            REMOVEFILTERS ( Events[EventDate] )
        )
    VAR _EventCount =
        CALCULATE (
            DISTINCTCOUNT ( Events[EventID] ),
            REMOVEFILTERS ( Presentations[PresentationTitle] )
        )
    RETURN
        DIVIDE ( _TotalAttendees, _EventCount )
  • Hi,

    Write these calculated column formulas

    Event count = =CALCULATE(DISTINCTCOUNT(Data[Event Date]),FILTER(Data,Data[Location]=EARLIER(Data[Location])))

    Attendee count = =CALCULATE(SUM(Data[Attendees]),FILTER(Data,Data[Location]=EARLIER(Data[Location])))

    Location average = =DIVIDE(Data[Attendee count],Data[Event count])

    Also, there are only 2 events in Location 2.

    Hope this helps.

    • tom-lenzmeier's avatar
      tom-lenzmeier
      Helper II

      Ashish,

      Thank you for your assistance. I am running into an error. I only have attendee names and SUM and SUMX throw errors.

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        I do not understand.  As you can see in my screenshot, my formulas are working.

  • Hi tom-lenzmeier  -Can you pleae try the below measure:

     

     

     

    Avg Attendees by Location =

    VAR CurrentLocation = MAX('Table'[Location])

    VAR TotalAttendees =
        CALCULATE(
            SUM('Table'[Attendees]),
            FILTER(
                ALL('Table'),
                'Table'[Location] = CurrentLocation
            )
        )

    VAR DistinctEvents =
        CALCULATE(
            DISTINCTCOUNT('Table'[EventID]),
            FILTER(
                ALL('Table'),
                'Table'[Location] = CurrentLocation
            )
        )

    RETURN
        DIVIDE(TotalAttendees, DistinctEvents)
  • tom-lenzmeier 

    could you pls provide some sample data ? not the table view , the data from three tables and how they connect to each other.