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
joggis
Regular Visitor

Rolling average of increasing value

Hi all,

 

I am now on the Power BI front and I am looking for some tips on how to do the following:

 

My data set:

CarN-CarsMiles-days
BMW133
BMW244
FORD110
FORD240
FORD320
FORD433

 

I want to calculate the following:

CarN-CarsMiles-daysaverage miles-day / N-Cars
BMW13333
BMW24438.5
FORD11010
FORD24025
FORD32023.33333333
FORD43325.75

 

Then plot this in a line diagram with Miles- days on Y-Axis and averaged value on X-axis.

For BMW it would be (1,33) next point (2,38.5).

 

Is there anybody here that could help with this?

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

hi @joggis ,

 

you can create a calculated column like this:

average miles-day / N-Cars =
VAR _currentNCar =
    CALCULATE ( SELECTEDVALUE ( cars[N-Cars] ) )
VAR _currentCar =
    CALCULATE ( SELECTEDVALUE ( cars[Car] ) )
RETURN
    DIVIDE (
        CALCULATE (
            SUM ( cars[Miles-days] );
            FILTER ( ALL ( cars ); cars[Car] = _currentCar && cars[N-Cars] <= _currentNCar )
        );
        _currentNCar
    )

 

here is example I made using the data you have provided: pbix

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @joggis 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please let me know.
 
Best Regards
Maggie
amitchandak
Super User
Super User

Try using the quick measure.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
sturlaws
Resident Rockstar
Resident Rockstar

hi @joggis ,

 

you can create a calculated column like this:

average miles-day / N-Cars =
VAR _currentNCar =
    CALCULATE ( SELECTEDVALUE ( cars[N-Cars] ) )
VAR _currentCar =
    CALCULATE ( SELECTEDVALUE ( cars[Car] ) )
RETURN
    DIVIDE (
        CALCULATE (
            SUM ( cars[Miles-days] );
            FILTER ( ALL ( cars ); cars[Car] = _currentCar && cars[N-Cars] <= _currentNCar )
        );
        _currentNCar
    )

 

here is example I made using the data you have provided: pbix

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

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