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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

DAX Query

Hi Community,

 

I am new to Power BI and hence I'd need help with DAX Formulas.

I have two columns 1) Week (the date values are in 7 days interval) 2)  Quantity

I would need the Minimum, Maximum and Average of Quantity based on the week column(Precisely past 6 weeks from the current week) - I will be using these aggregates in the Line values in a chart over the weeks. My question is:

1) Do I create a Measure or a new column

2)  Syntax of the Dax query would be helpful.

 

Thanks 🙂

2 REPLIES 2
Anonymous
Not applicable

Hopefully this should set you on your way:

 

SixWeeksHence = lastdate(DATESINPERIOD(quantityTable[Week],calculate(firstdate(quantityTable[sixWeeksPrevious])),7*7,day))

FromDate = FIRSTDATE(DATESINPERIOD(quantityTable[Week],calculate(firstdate(quantityTable[sixWeeksPrevious])),7*7,day))

MinQuant = 
MINx(
    filter(quantityTable,
    quantityTable[Week] < earlier(quantityTable[SixWeeksHence]) && 
    quantityTable[Week] >= earlier(quantityTable[FromDate]))
    ,quantityTable[Quantity])

AvgQuant = 
AVERAGEX(    
    filter(quantityTable,
    quantityTable[Week] < earlier(quantityTable[SixWeeksHence]) && 
    quantityTable[Week] >= earlier(quantityTable[FromDate]))
    ,quantityTable[Quantity])

MaxQuant = 
MAXX(    
    filter(quantityTable,
    quantityTable[Week] < earlier(quantityTable[SixWeeksHence]) && 
    quantityTable[Week] >= earlier(quantityTable[FromDate]))
    ,quantityTable[Quantity])

 

Data in PBI:

data2.png

 

Data in Excel confirming results:

data2ex.png

 

 

Cristian_Angyal
Most Valuable Professional
Most Valuable Professional

Do you have a sample dataset and the required end-result? It would be much easier

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Solution Authors