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
cplesner
Helper III
Helper III

Measure for calculating age at selected point in time and the filter

I have a challenge for whoever have a deep understanding of the inner workings of the formular engine. It seems that depending on where the filter is applied (filter pane or column within a visual), the performance is very differnt and the queryplan completely changes.

 

The measure is rather "simple" - For whatever period the users selects, calculate the Age in Years of the "Product" at the min(date) of the selection. Afterwards filter out only those ages that are selected.... Below query solves the problem, but the challenge is when it's over millions of rows and the period needs to be in the colum of the visual (ex. number of product at a certain age pr, month)

 

 

 

 

Number of products = 
VAR MinDate = MIN ( 'CalendarDate'[Date] )

VAR Calc =
CALCULATE (
            COUNTROWS ( 'Product' ),
            'Product'[DW_ValidFrom] <= MinDate,
            'Product'[DW_ValidTo] >= MinDate,
            all ('CalendarDate'),
            FILTER ( 
                 'Product', 
                VAR AgeCalculated = 
                    IF ( 
                        'Product'[PurchaseDate] <= MinDate, 
                         TRUNC(YEARFRAC( 'Product'[PurchaseDate], MinDate ) ) 
                    ) 
                RETURN 
                    CONTAINS ( VALUES ( 'Age'[AgeYearINT] ), 'Age'[AgeYearINT], AgeCalculated ) 
            )                       
        ) 
        
RETURN 
Calc

 

 

 

 

Samplefile can be found here: SCD2 Age calc.pbix

 

Problem is also described more in detail here:

https://community.powerbi.com/t5/Desktop/Calculating-point-in-time-age-of-persons-and-filtering-them...

 

Challenge is to get the left visual to perform better (so that multiple periods can be added) - and remove all the unneccesary calculations as found in the Server timings.

2 REPLIES 2
cplesner
Helper III
Helper III

If anyone is up for the challenge - then this problem is still unsolved! 🙂

cplesner
Helper III
Helper III

Just to clarify - the current measure definition is calulcating correct - it's just the performance that suffers when volume gets into the millions of rows

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors