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! Learn more

Reply
SammyNed
Helper I
Helper I

dynamic median filter

Good Day

 

We are struggling to get a dynamic median filter. 

 

Please see some sample data below:

The portion on the left in blue is the sample data.

 

On the right is some calculations we have done in powerbi.

We use the datadiff function to get the: Time to move states (time to new state and time to contacted state) as well as the Time currently still in new state (time to new state and Today); then we use the median and average functions.

 

We want to highlight the leads that are currently still in a new state but outside the median of those that already moved on.

So lead A should be highlighted because it is at 4.1 days which is greater than the median of 1.13 days. 

 

But this must all be dynamic as new leads will come in daily and change the overall median, plus if we want to filter for a certain period then the median must reflect that period. 

SammyNed_0-1733906307514.png

 

end result is a simple card visual showing how many leads are in a New state and currently outside the median (1 in this case)

 

Can anyone assist?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SammyNed ,

I create a table as you mentioned.

vyilongmsft_0-1733970873367.png

Then I create two calculated columns.

TimeToNewState = DATEDIFF([Time moved to New State], TODAY(), DAY)
TimeToContactedState = DATEDIFF([Time moved to New State], [Time moved to Contacted State], DAY)

vyilongmsft_1-1733972124957.png

Next I think you can create two measures and a calculated column.

MedianTimeToContacted = MEDIANX(
    FILTER(
        'Table',
        NOT(ISBLANK([TimeToContactedState]))
    ),
    [TimeToContactedState]
)
IsOutsideMedian = IF(
    AND(
        [Current State] = "New",
        [TimeToNewState] > [MedianTimeToContacted]
    ),
    1,
    0
)

vyilongmsft_2-1733972564001.png

LeadsOutsideMedian = CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        'Table',
        [IsOutsideMedian] = 1
    )
)

 

vyilongmsft_3-1733972802907.png

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @SammyNed ,

I create a table as you mentioned.

vyilongmsft_0-1733970873367.png

Then I create two calculated columns.

TimeToNewState = DATEDIFF([Time moved to New State], TODAY(), DAY)
TimeToContactedState = DATEDIFF([Time moved to New State], [Time moved to Contacted State], DAY)

vyilongmsft_1-1733972124957.png

Next I think you can create two measures and a calculated column.

MedianTimeToContacted = MEDIANX(
    FILTER(
        'Table',
        NOT(ISBLANK([TimeToContactedState]))
    ),
    [TimeToContactedState]
)
IsOutsideMedian = IF(
    AND(
        [Current State] = "New",
        [TimeToNewState] > [MedianTimeToContacted]
    ),
    1,
    0
)

vyilongmsft_2-1733972564001.png

LeadsOutsideMedian = CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        'Table',
        [IsOutsideMedian] = 1
    )
)

 

vyilongmsft_3-1733972802907.png

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.