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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
El_Bastien
Frequent Visitor

Line Graph Aggregate instead of Average

Hi, I'm having issues with a visual. I want the average headcount by employee type by a quarter displayed on a line graph. This is the formula I have to get the average.

 

Avg Headcount = 
    AVERAGEX(
        VALUES('FY25'[Employee Type]),
        CALCULATE(SUM('FY25'[Count]))
    )

 
When adding that to the line graph it displays this.

Screenshot 2024-10-29 at 1.19.17 p.m..png

 

The line graph format is the one I'm looking for, showing each quarter by month. However, the values do not give the average but the aggregation. Any ideas on how to do this?

 

To give you some extra details, these are the Tables and Columns I'm using

Table 1
- Employee Name

- Employee Type

- Count (Just a 1 assigned to each column)
- Period (Month Starting Date)

Calendar

Calendar = 

--Inputs--
VAR WeekStartsOn = "Mon"
VAR FiscalStartMonth = 7 

--NOTE: Calendar week starts from Monday

--Calculation--
RETURN
    ADDCOLUMNS (
        CALENDARAUTO ( FiscalStartMonth - 1 ),
        "MIndex", MONTH ( [Date] ),
        "FiscalMIndex", MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ),
        "CalMonth", FORMAT ( [Date], "mmm" ),
        "CalQtr", "Q"
            & CEILING ( MONTH ( [Date] ), FiscalStartMonth - 1 ) / ( FiscalStartMonth - 1 ),
        "CalYear", YEAR ( [Date] ),
        "Fiscal Week",
        VAR FiscalFirstDay =
            IF (
                MONTH ( [Date] ) < FiscalStartMonth,
                DATE ( YEAR ( [Date] ) - 1, FiscalStartMonth, 1 ),
                DATE ( YEAR ( [Date] ), FiscalStartMonth, 1 )
            )
        VAR FilteredTableCount =
            COUNTROWS (
                FILTER (
                    SELECTCOLUMNS ( GENERATESERIES ( FiscalFirstDay, [Date] ), "Dates", [Value] ),
                    FORMAT ( [Dates], "ddd" ) = WeekStartsOn
                )
            )
        VAR WeekNos =
            IF (
                FORMAT ( FiscalFirstDay, "ddd" ) <> WeekStartsOn,
                FilteredTableCount + 1,
                FilteredTableCount
            )
        RETURN
            "Week " & WeekNos,
        "Fiscal Qtr", "Q"
            & CEILING ( MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ), 3 ) / 3,
        "Fiscal Year",
        VAR CY =
            RIGHT ( YEAR ( [Date] ), 2 )
        VAR NY =
            RIGHT ( YEAR ( [Date] ) + 1, 2 )
        VAR PY =
            RIGHT ( YEAR ( [Date] ) - 1, 2 )
        VAR FinYear =
            IF ( MONTH ( [Date] ) > ( FiscalStartMonth - 1 ), NY , CY )
        RETURN
            FinYear,
        "CalWeekNo", WEEKNUM ( [Date], 2 ),
        "Weekend/Working", IF ( WEEKDAY ( [Date], 2 ) > 5, "Weekend", "Working" ),
        "Day", FORMAT ( [Date], "ddd" )
    )

 
Thanks in advance for the help!

2 REPLIES 2
Anonymous
Not applicable

Hi @El_Bastien  ,

 

Could you share the sample data and the expected outputs?

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

 

Best Regards,

Wearsky

EmployeeCategoryMonthPeriodCount
904GTApril01/04/241
54AApril01/04/241
363CMay01/05/241
1DMay01/05/241
54AMay01/05/241
591CJune01/06/241
1DJune01/06/241
54AJune01/06/241
489CJuly01/07/241
1DJuly01/07/241
54AJuly01/07/241
591CAugust01/08/241
1DAugust01/08/241
54AAugust01/08/241
591CSeptember01/09/241
1DSeptember01/09/241
244DSeptember 01/09/241
54ASeptember01/09/241
1DOctober01/10/241
54AOctober01/10/241

 

Here is the sample data.

 

Ignore the "Employee" column as it is unimportant to the problem.

 

The expected outputs are:

Average Quarterly Headcount by Category. In my first message, I inserted a picture of what the line chart has to be like. The problem with that is that PBI aggregates each quarter, and I need the average. for example if: M1=100, M2=105, M3=110, the Q1avg = 105. The average must be shown when displaying the year and the quarter (as shown in the picture). If necessary, we can add the month as the lowest level, but that is optional.

Thank you so much! @Anonymous 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors