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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
armonz
Frequent Visitor

Obtain the total from a selection of rows retroactively filled with a lastnonblank formula

I have a data set that get new versions daily, this data set has four columns: version, date, basket and apples. Basically this tells us how many apples are, or will be, in a basket every single day, but whenever we get a new version we lose the data from the previous day version.

This is how the data would look when looking at the version from the 3th

Datedata with no formula
1st 
2nd 
3th1
4th3
5th6


this is how it would look when looking at a version from the 4th (future numbers can change as they update)

Datedata with no formula
1st 
2nd 
3th 
4th3
5th7


Using this formula I was able to fill the blanks we have for previous dates on newer versions using data from previous versions. FYI: Versions are copied to another table to be used as reference.

 

 

 

 

SUMMARY_APPLES = 
IF(
    ISBLANK( MAX( SUMMARY_APPLES[# OF APPLES] ) ),
    CALCULATE(
        LASTNONBLANK( SUMMARY_APPLES[# OF APPLES], SUMMARY_APPLES[# OF APPLES]),
        FILTER(
            ALL( SUMMARY_VERSIONS ),
            SUMMARY_VERSIONS[VERSION #] < MAX( SUMMARY_VERSIONS[VERSION #])
        )
    ),
    MAX( SUMMARY_APPLES[# OF APPLES] )
)

 

 

 

 

 
This is a comparison of how the data looks before and after the formula (when looking at a version from the 4th):

Datedata with no formuladata with formula
1st 2
2nd 3
3th 1
4th33
5th77
Total1010


As seen in the Total row, my problem arises when I try to get the total, as it only sums the originally non blank values. I know this happens because LASTNONBLANK does not work on an aggregation level, only on a row basis level, but is there any way to obtain the total sum INCLUDING all the values? (IE: total being 16 instead of 10)

2 REPLIES 2
Anonymous
Not applicable

Hi, @armonz 

Please provide more details with your desired output and pbix file without privacy information (or some sample data)

 

Best Regards

Yongkang Hua

Thank you for the reply, @Anonymous.

I can't provide sample data due to privacy issues, but hopefully this explains it:

Below it's a rough example of how the data is recevied

versiondatebasketapples
2024/12/03 2024/12/03basket 13
2024/12/03 

2024/12/04

basket 11
2024/12/03 2024/12/05basket 16
............
2024/12/03 2024/12/31basket 15
2024/12/04 2024/12/04basket 11
2024/12/04 2024/12/05basket 16
2024/12/04 2024/12/06basket 18
............
2024/12/04 2024/12/31basket 15

 

You can ignore the basket columns, that is basically used as a slicer for different baskets. The important part is as you can see every version has data for the entire month, we get a new version every day, but every new version starts with the day on which it was sent and has no data for past dates. 

This means that if I want to see the data for the entire month of December, using the latest version I would be showing a table like this:

Datedata with no formula
1st 
2nd 
3th 
4th3
5th

7

 

Using the before mentioned formula I am able to fill the blanks with the data from previous versions, like so:

Datedata with no formuladata with formula
1st 2
2nd 3
3th 1
4th33
5th77
Total1010


I have a separate view where I want to show the total sum for the entire month, no matter the version I'm looking at, but at this point the formula only aggregates the numbers available in each version, ignoring the values that were filled with data from previous versions. In the table above the total shows as 10, when I need to show 17. 

I hope this explains how the data works and my issue. Thanks, again.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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