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
RashmitaR
Helper IV
Helper IV

Dax

Hi ,

I have a dataset with one of its column as date and one more as close price ,I wanted to find the average of close price for the last 7 dates present in my date column for every row.For eg

DateClose Price7Day15Day30day
8-Apr-1614.1214.1113.6566713.81167
7-Apr-1614.2414.0813.6186713.781
6-Apr-1614.0613.8842913.5906713.75133
5-Apr-1613.7813.7328613.6006713.721
4-Apr-1614.2713.6842913.62213.705
1-Apr-1614.1513.5657113.6206713.67433
31-Mar-1614.1513.4042913.64613.661
30-Mar-1613.9113.2428613.66813.66433
29-Mar-1612.8713.1671413.7406713.654
28-Mar-161313.2642913.8833313.655
23-Mar-1613.4413.3814313.93613.67833
22-Mar-1613.4413.4914313.9406713.73533
21-Mar-1613.0213.5857113.9446713.81233
18-Mar-1613.0213.7614313.9633313.90333

 

Thanks,

Rashmita Reddy

4 REPLIES 4
achinm45
Advocate IV
Advocate IV

Hi @RashmitaR

Try following :

 

1 ) Create an Index column by going into Power Query part of Power BI (click Edit Queries) and then under transformmations.

2) Then write formula as in screenshot here :

 

Last7Days.jpg3) Write similarly for other metrics

 

Cheers !

Achin

Sean
Community Champion
Community Champion

@RashmitaR This Measure should work... Let me know.

 

7 Day Avg =
DIVIDE (
    CALCULATE (
        SUM ( Table[Close Price] ),
        DATESINPERIOD ( Table[Date], LASTDATE ( Table[Date] ), -7, DAY )
    ),
    CALCULATE (
        DISTINCTCOUNT ( Table[Date] ),
        DATESINPERIOD ( Table[Date], LASTDATE ( Table[Date] ), -7, DAY )
    ),
    0
)

 

Thank you for reply. I have created a column using your suggestion but while creating another one for 15day average i am getting a circular dependency hence i am unable to create it . Could you please help me by letting me know how to deal with this issue .

 

Thanks ,

Rashmita Reddy.

Hi @Sean,

Thanks for perspective. However dates are not contigous 🙂

 

BR,
Achin

 

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