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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Yuiitsu
Helper V
Helper V

How to Get Value from Previous Row if Blank (Across Three Measures from Different Tables)

Hi all,

 

I’m trying to build a visual in Power BI that shows the following:

Date

HQ Sales (SUM measure from Table A)

EU Sales (SUM measure from Table B)

Budget (SUM measure from Table B)

All tables are linked through a Date table, and the Date field is used.

 

Requirement: If a measure returns blank for a date, I would like it to display the most recent non-blank value from previous dates.

 

In a seperate thread I have the solution for 2 different tables but now I wish to add in a 3rd table.

Using this link to the sample BI (File Link  ) here, could anyone help to modify to suit this new requirement?

1 ACCEPTED SOLUTION
v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

Please find the attached PBIX file for your reference.Done few changes in the file, hope it will help.

Thank you.

View solution in original post

20 REPLIES 20
v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

I hope the information provided is helpful.I wanted to check whether you were able to resolve the issue with the provided solutions.Please let us know if you need any further assistance.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

Please find the attached PBIX file for your reference.Done few changes in the file, hope it will help.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

Thank you for the clarification.

Can you please help me with the exact output you are expecting like what are the values that should be filled in the blanks, so that will try to implement the same thing.

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

Below is your expected output given in your previous post:

vvenuppu_0-1755087881292.png

You can see the same output from my attached file:

vvenuppu_1-1755087977716.png

Please let us know if you need any further assistance.

Thank you.

Hi

 

I think you misunderstood my message. Here is what I wrote:

"Below is how it looks like without any measures to fill up the blanks.

I only want the blanks filled up in these dates ......"

 

The sceenshot below is showing you that without any measure, this is how it looks like.

What I expect is the blanks in the screenshot to be filled up.

Yuiitsu_0-1755131846235.png

 

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

I have tried replicating the same output, done few changes in measures.

Please go through the attached PBIX file for your reference.

 

Thank you.

This is the output?

 

Yuiitsu_1-1755054975220.png

 

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

I have done some changes in the sample file.

1.Created a helper table called LastNonBlankDates.

2.Then created three new measures.(HQ Sales Blanks Filled_New,EU Sales Blanks Filled_New,Budget Blanks Filled_New).I hope this helps..!!

Please go through the attached PBIX file for your reference.

Thank you.

Hi @v-venuppu 

 

Thanks, but the result is still not what I am looking for.

Below is how it looks like without any measures to fill up the blanks.

I only want the blanks filled up in these dates but using your measures i will have blanks filled up in every single date inside the date key.

Yuiitsu_0-1754894930874.png

 

Your measure result:

Yuiitsu_1-1754895029797.png

 

 

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

I have tried replicating the scenario by using sample data.Please go through the attached PBIX file for your reference.

Thank you.

Hi @v-venuppu 

 

Your solution works but in my case i am using measures not the exact column inside the data.

If you look at my sample, i have 3 measures and i want to use them instead of the exact column is it possible?

Yuiitsu_0-1754527532191.png

 

Also in my data, EU, BU sales and budget does not exist in the same data set. They are 3 different tables.

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Yuiitsu ,

Thank you for reaching out to Microsoft Fabric Community.

Thank you @Ashish_Mathur @ThxAlot @burakkaragoz @GrowthNatives for the prompt response.

I wanted to check if you had the opportunity to review the information provided by @Ashish_Mathur and resolve the issue..?Please let us know if you need any further assistance.We are happy to help.

Thank you.

Doesnt work at this moment I am still trying to fit it into my actual data file😣

Ashish_Mathur
Super User
Super User

Hi,

Reduce the size of your Calendar table by using this formula

Date = 

ADDCOLUMNS (

CALENDAR (DATE (2025, 4, 1), DATE (2025, 07, 31)),

"Year", YEAR([Date]),
"Year-Month", FORMAT ( [Date], "yyyy-mmmm" ),
"MonthNumber", MONTH([Date])
)

Revised your measure to

EU Sales Blanks Filled = if((ISBLANK([HQ Sales])&&ISBLANK([EU Sales])&&ISBLANK([Budget])),BLANK(),CALCULATE([EU Sales],CALCULATETABLE(LASTNONBLANK('Date'[Date],CALCULATE([EU Sales])),DATESBETWEEN('Date'[Date],MINX(ALL('Date'),'Date'[Date]),MAX('Date'[Date])))))
HQ Sales Blanks Filled = if((ISBLANK([HQ Sales])&&ISBLANK([EU Sales])&&ISBLANK([Budget])),BLANK(),CALCULATE([HQ Sales],CALCULATETABLE(LASTNONBLANK('Date'[Date],CALCULATE([HQ Sales])),DATESBETWEEN('Date'[Date],MINX(ALL('Date'),'Date'[Date]),MAX('Date'[Date])))))

Hope this helps.

Ashish_Mathur_0-1753747514995.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ThxAlot
Super User
Super User

Easy enough,

ThxAlot_0-1753687529342.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Hi @ThxAlot 

 

The first 2 columns must be all filled from previous row as well.

As you can see from my screenshot below that without the budget column they work well.

Yuiitsu_0-1753693337562.png

 

But once the budget is added in the blanks appear

Yuiitsu_1-1753693379374.png

 

Apologise for not explaining it detailed enough earlier.

 

 

burakkaragoz
Community Champion
Community Champion

Hi @Yuiitsu ,

 

That DAX code has some issues and won't work properly for what you're trying to do. The logic is flawed because it's using MAX on what should be SUM measures, and the filtering isn't quite right.

Here's the correct approach for each of your three measures:

HQ Sales (Forward Fill) = 
VAR CurrentDate = MAX('Date'[Date])
VAR CurrentValue = [HQ Sales Original]
VAR LastNonBlankValue = 
    CALCULATE(
        [HQ Sales Original],
        FILTER(
            ALL('Date'[Date]),
            'Date'[Date] <= CurrentDate && 
            NOT(ISBLANK([HQ Sales Original]))
        ),
        LASTDATE('Date'[Date])
    )
RETURN
IF(ISBLANK(CurrentValue), LastNonBlankValue, CurrentValue)
EU Sales (Forward Fill) = 
VAR CurrentDate = MAX('Date'[Date])
VAR CurrentValue = [EU Sales Original]
VAR LastNonBlankValue = 
    CALCULATE(
        [EU Sales Original],
        FILTER(
            ALL('Date'[Date]),
            'Date'[Date] <= CurrentDate && 
            NOT(ISBLANK([EU Sales Original]))
        ),
        LASTDATE('Date'[Date])
    )
RETURN
IF(ISBLANK(CurrentValue), LastNonBlankValue, CurrentValue)
Budget (Forward Fill) = 
VAR CurrentDate = MAX('Date'[Date])
VAR CurrentValue = [Budget Original]
VAR LastNonBlankValue = 
    CALCULATE(
        [Budget Original],
        FILTER(
            ALL('Date'[Date]),
            'Date'[Date] <= CurrentDate && 
            NOT(ISBLANK([Budget Original]))
        ),
        LASTDATE('Date'[Date])
    )
RETURN
IF(ISBLANK(CurrentValue), LastNonBlankValue, CurrentValue)

Key differences from the suggested answer:

  • Uses your actual SUM measures instead of MAX on base columns
  • Properly handles the forward-fill logic with LASTDATE
  • Checks if current value is blank first, only then looks backward

Make sure your original measures are named something like:

  • [HQ Sales Original] for your Table A SUM
  • [EU Sales Original] for your Table B SUM
  • [Budget Original] for your Table B budget SUM

This approach works consistently across multiple tables and handles the date relationships properly through your Date table.


If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was assisted by AI for translation and formatting purposes.

Thank you @burakkaragoz

Just to double confirm you are requesting me to change my following measure

Yuiitsu_2-1753693645759.png

to :

  • [HQ Sales Original] for your Table A SUM
  • [EU Sales Original] for your Table B SUM
  • [Budget Original] for your Table B budget SUM

 

Would it be possible for you to work the magic in my sample file and share it with me so I can understand it better?

GrowthNatives
Continued Contributor
Continued Contributor

Hi @Yuiitsu , 
You can create measures with forward-fill logic. This will ensure that blanks are replaced with the most recent non-blank value from earlier dates.

Here is the code you can use for creating measures & similarly for EU Sales and Budget

DAX 
HQ Sales (Forward Fill) =
VAR CurrentDate = MAX('Date'[Date])
RETURN
CALCULATE(
    CALCULATE(MAX('Table A'[HQ Sales])),
    FILTER(
        ALL('Date'),
        'Date'[Date] <= CurrentDate &&
        NOT(ISBLANK(CALCULATE(MAX('Table A'[HQ Sales]))))
    )
)

 
Hope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
💡Found it helpful? Show some love with kudos 👍 as your support keeps our community thriving!
🚀Let’s keep building smarter, data-driven solutions together! 🚀 [Explore More]

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!

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