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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
cdawidow2
Frequent Visitor

Last Value from a table?

Hi guys, I want to build a dax measure that essentially allows me to calculuate the Stage Name & Amount of a sales opportunity in my pipeline historically.   I have both CreatedDate and systemmodstamp which essentially tracks the recency of these values but my measures unfortuantely my measures always sum the totals when the same createddate is shown as shown below.  Any ideas on which function to use?

LASTBLANK.PNG

 

3 REPLIES 3
cdawidow2
Frequent Visitor

NVM Amit, I manged to get the correct totals using sumx !  My bad.  Pretty easy fix.  I am just starting out but I have 1 issue I cannot wrap my head around shown below:   My formula should retrieve just 1 last historic stage but in this instance it retrieves multiple?  Why is that ?  I am thinking it is due to my formula but could you help me fix this issue to only retrieve 1 historic stage with its correct amount ?  It cannot have multiple stages as it will skew the measures wrong stages.PNG

 

cdawidow2
Frequent Visitor

Hi Amit,

 

I cannot share my file but perhaps I can make it much clearer for you.  Below is an example from my file.  

Essentially, I set my date filter so be sometime in the past.  Now if I select an Opportunity, ( Academic Renewal), below I get their respective stage history.  My measures I built out correctly retrieve the last value for both its historic stage and amount which was on March 3rd 2021 as it is the lastnonblank date within the date filters applied.  My measure fpr historical amount is below.  

 

HISTORICAL AMOUNT = VAR X = calculate(MAXX(VALUES('Opportunity History'[SystemModstamp]),'Opportunity History'[SystemModstamp]))
RETURN


CALCULATE(FIRSTNONBLANK('Opportunity History'[Amount],'Opportunity History'[Amount]),'Opportunity History'[SystemModstamp]=X)


historic.PNG

 

My issue is how do I correctly sum each respect opportunity lastnonblank historical amount when these date filters are applied?  As of now I am not getting the correct result as shown below .  The total value is super low.  My question is how do i essentially sum up all these lastnonblank values up for a correct total amount? wrong totals.PNG

 

amitchandak
Super User
Super User

@cdawidow2 , the expected output is not clear

 

Try

lastnonblankvalue(CreatedDate , Sum(Table[Amount]) // Or use Amount Measure

 

lastnonblankvalue(systemmodstamp , Sum(Table[Amount]) // Or use Amount Measure

 

or

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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.