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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
AdamRobC
Helper II
Helper II

Using EARLIER function to return an earlier non-zero value based on column criteria

Hi, I am trying to write some DAX that looks for an earlier non-zero value of a column based on multiple column criteria.

e.g. for row 3 below it would return the most 'recent' non-zero value where both SKU and Country match i.e. 15.40

 

I've had some joy using the below but it's not really working as I want it to:

Test = CALCULATE(MAX('Price Lookup'[Current Price (€)]),FILTER('Price Lookup','Price Lookup'[Config-SKU]=EARLIER('Price Lookup'[Config-SKU]) && 'Price Lookup'[Country]=EARLIER('Price Lookup'[Country])))
 

AdamRobC_1-1625197035619.png

AdamRobC_0-1625196954581.png

Thanks!

1 REPLY 1
amitchandak
Super User
Super User

@AdamRobC , this one seems correct. check do you have any other row, which is causing that or you need any additional filter

 

you can try this too


Test = MAXX(FILTER('Price Lookup','Price Lookup'[Config-SKU]=EARLIER('Price Lookup'[Config-SKU]) && 'Price Lookup'[Country]=EARLIER('Price Lookup'[Country])),'Price Lookup'[Current Price (€)])

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors