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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
saavedrag12
Frequent Visitor

How to find the start date and end date of a maximum value?

Hello, 

 

I'm trying to figure out a way for Power BI to call out a a start and end date of a maximum value. So for context, I am working with headcount data. Our headcout over a duration of a project looks a lot like a bell curve, however, once the peak headcount is reached, it stays at that amount for a number of weeks before declining again. I want to create a dynamic measure that calls out the individual weeks that the peak starts and ends. 

 

Here is our formula to get the actual peak headcount amount (sum of headcount divied up by discipline): 

 

Measure_Peak_HC= SUMX(SUMMARIZE(DisciplineTable, DisciplineTable[discipline], "Max HC", MAX(HeadcountTable[Headcount])), [Max HC])

 

Now we're trying to create a measure that finds the start and end date (work week) of that peak HC. 

 

Any tips or tricks would help!!

 

 

1 ACCEPTED SOLUTION

@saavedrag12 

Sorry O wrote the wrong variable name. Here modied

Peak Start & End =
VAR MaxCount = [Measure_Peak_HC]
VAR PeakWeeks =
    FILTER (
        VALUES ( 'Date'[Column_WW_YR] ),
        CALCULATE ( SUM ( TableName[HeadCount] ) ) = PeakWeeks
    )
VAR MinWeek =
    MINX ( PeakWeeks, 'Date'[Column_WW_YR] )
VAR MaxWeek =
    MAXX ( PeakWeeks, 'Date'[Column_WW_YR] )
RETURN
    "Peak Count of " & MaxCount & " within " & MinWeek & " - " & MaxWeek

 

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @saavedrag12 

please try

 

 

Peak Start & End =
VAR MaxCount = [Measure_Peak_HC]
VAR PeakWeeks =
    FILTER ( VALUES ( 'Date'[Column_WW_YR] ), [HeadCount] = PeakWeeks )
VAR MinWeek =
    MINX ( PeakWeeks, 'Date'[Column_WW_YR] )
VAR MaxWeek =
    MAXX ( PeakWeeks, 'Date'[Column_WW_YR] )
RETURN
    "Peak Count of " & MaxCount & " within " & MinWeek & " - " & MaxWeek

 

 

Hello, 

It doesn't allow me to select the headcount column when creating the second variable :

saavedrag12_0-1654544950026.png

 

 

@saavedrag12 

I thought head count is a measure. So it is just a coulmn summarized by sum?

then please try 

Peak Start & End =
VAR MaxCount = [Measure_Peak_HC]
VAR PeakWeeks =
    FILTER (
        VALUES ( 'Date'[Column_WW_YR] ),
        CALCULATE ( SUM ( TableName[HeadCount] ) ) = PeakWeeks
    )
VAR MinWeek =
    MINX ( PeakWeeks, 'Date'[Column_WW_YR] )
VAR MaxWeek =
    MAXX ( PeakWeeks, 'Date'[Column_WW_YR] )
RETURN
    "Peak Count of " & MaxCount & " within " & MinWeek & " - " & MaxWeek

saavedrag12_0-1654551404676.png

It's not recognizing the variable in the calculate statement 

@saavedrag12 

Sorry O wrote the wrong variable name. Here modied

Peak Start & End =
VAR MaxCount = [Measure_Peak_HC]
VAR PeakWeeks =
    FILTER (
        VALUES ( 'Date'[Column_WW_YR] ),
        CALCULATE ( SUM ( TableName[HeadCount] ) ) = PeakWeeks
    )
VAR MinWeek =
    MINX ( PeakWeeks, 'Date'[Column_WW_YR] )
VAR MaxWeek =
    MAXX ( PeakWeeks, 'Date'[Column_WW_YR] )
RETURN
    "Peak Count of " & MaxCount & " within " & MinWeek & " - " & MaxWeek

 

saavedrag12
Frequent Visitor

saavedrag12_0-1654532844651.png

For example: I want to create a measure that will call out the start date (and end date) of the peak HC (WW circled in green). So in this case, if I were to put the measure on the card, it will call out the value/date : WW 37.22 (this is from our calendar table)

Hi, can you share some sample data?

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.