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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Max date period as part of calculation

Hi all

 

New to PowerBI and have come over from Qlik usage. I am trying to create a measure that gives me the latest value for a sales measure where in Qlik I would use the MAX(Period) as a way to force the KPI I create to show only that value.

 

I tried to do the same with PowerBI after reading some forum posts here but am getting stuck with an error message. 

 

My expression is as follows:

 

Current Sales Growth = CALCULATE(average('Prod Data'[Sales]),'Prod Data'[Period]=MAX('Prod Data'[Period]))

 

I have verified using a card object that doing MAX('Prod Data'[Period]) gives me the right value in the data and that when I manually entered a date in the above (eg 'Prod Data'[Period]=VALUE("30/09/2017")) that this also worked.

 

However I'd like the calc to be dynamic instead of static for the dataset.

 

Any help is appreciated thank you!

1 ACCEPTED SOLUTION
DAX0110
Resolver V
Resolver V

Hi @Anonymous, try this version:

 

Current Sales Growth =

    VAR lastPeriod = MAX('Prod Data'[Period])

    RETURN CALCULATE(average('Prod Data'[Sales]),'Prod Data'[Period]=lastPeriod)

 

 

View solution in original post

3 REPLIES 3
DAX0110
Resolver V
Resolver V

Hi @Anonymous, try this version:

 

Current Sales Growth =

    VAR lastPeriod = MAX('Prod Data'[Period])

    RETURN CALCULATE(average('Prod Data'[Sales]),'Prod Data'[Period]=lastPeriod)

 

 

Anonymous
Not applicable

Did not know variables could be used that way, that is brilliant!

 

I wonder why I could not just put it all inthe one script though? Is that nuance particular to PowerBI?

 

thanks for your quick help!

Hi @Anonymous, if you're interested in delving deeper into this intriguing phenomenon, I'd suggest this page:

 

https://powerpivotpro.com/2012/06/filter-when-why-how-to-use-it/

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors