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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Pk8524
Helper I
Helper I

Data label only for Max Value with Time Aggregation parameter

Hi Guys,

 

How to show only one data label with Max value for certain Time aggregation parameter?

 

01.jpg

 

I am using following parameter:

 

Time Aggregation = {
    ("Year", NAMEOF('dimCalendar'[Year]), 0),
    ("Quarter", NAMEOF('dimCalendar'[Quarter]), 1),
    ("Month", NAMEOF('dimCalendar'[Month]), 2)
}

 

Link to file:

https://drive.google.com/file/d/1zX0aBAOcYPi3IIF0-N2Mh-0_j-f-as3D/view?usp=sharing 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can create a new measure

Total Sales Data Label = 
VAR CurrentValue = [Total Sales]
VAR MaxValue = SWITCH(
    SELECTEDVALUE( 'Time Aggregation'[Time Aggregation Order] ),
    0, -- Year 
    MAXX(
        ALLSELECTED( dimCalendar[Year] ),
        [Total Sales]
    ),
    1, -- Quarter 
    MAXX(
        ALLSELECTED( dimCalendar[Quarter] ),
        CALCULATE( [Total Sales], REMOVEFILTERS( dimCalendar[QuarterNr] ) )
    ),
    2, -- Month 
    MAXX(
        ALLSELECTED( dimCalendar[Month] ),
        CALCULATE( [Total Sales], REMOVEFILTERS( dimCalendar[MonthNr] ) )
    )
)
VAR Result = IF( CurrentValue = MaxValue, CurrentValue )
RETURN Result

and use that as the value for the data labels on the chart visual.

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You can create a new measure

Total Sales Data Label = 
VAR CurrentValue = [Total Sales]
VAR MaxValue = SWITCH(
    SELECTEDVALUE( 'Time Aggregation'[Time Aggregation Order] ),
    0, -- Year 
    MAXX(
        ALLSELECTED( dimCalendar[Year] ),
        [Total Sales]
    ),
    1, -- Quarter 
    MAXX(
        ALLSELECTED( dimCalendar[Quarter] ),
        CALCULATE( [Total Sales], REMOVEFILTERS( dimCalendar[QuarterNr] ) )
    ),
    2, -- Month 
    MAXX(
        ALLSELECTED( dimCalendar[Month] ),
        CALCULATE( [Total Sales], REMOVEFILTERS( dimCalendar[MonthNr] ) )
    )
)
VAR Result = IF( CurrentValue = MaxValue, CurrentValue )
RETURN Result

and use that as the value for the data labels on the chart visual.

why it is needed to remove filters on quarternr in case of quarter?

That column is used to sort the Quarter column, same for Month number and month. Because they are used for sorting they are included in the underlying query generated for the visual, and are therefore in the filter context when the measure is calculated for a given month / quarter. We need to remove those filters so that we get the right total.

why it is needed to remove filters on quarter nr?

 

MAXX(
        ALLSELECTED( dimCalendar[Quarter] ),
        CALCULATE( [Total Sales], REMOVEFILTERS( dimCalendar[QuarterNr] ) )
    ),

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.