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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
11097486
Helper I
Helper I

Find previous blank value in previous rows

Hello, I want to be able to retrieve the value of Date1 of the previous Column1 = empty. 

The result I want is in the 3rd column identified by the red arrow. As you can see, the result can repeat itself since it will search the previous empty colum1 value.

 

Thank you

 

11097486_0-1611585907329.png

 

1 ACCEPTED SOLUTION

Hi @11097486 ,

You can create a calculated column like this:

Re =
CALCULATE (
    MAX ( 'Table'[Date1] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Date1] < EARLIER ( 'Table'[Date1] )
            && 'Table'[Column1] = BLANK ()
    )
)

date.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
vanessafvg
Super User
Super User

can you provide some dummy data in text form?  

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hello, the data is the first 2 columns of the print screen. Thank you

you need to provide in a usable format, you cannot copy and paste that.  If you need help its preferable you provide it in a usable format.

 

How do you know the sequence of the data is it date sorted?   what if you have duplicates or is it unique dates only?

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hello, yes it is date sorted and there won't be any duplicates. I cannot insert files. Creating the table should take 2 minutes... Thank you

 

 

11097486_0-1611594838551.png

 

 

Hi @11097486 ,

You can create a calculated column like this:

Re =
CALCULATE (
    MAX ( 'Table'[Date1] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Date1] < EARLIER ( 'Table'[Date1] )
            && 'Table'[Column1] = BLANK ()
    )
)

date.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, Can you please help me with a similar query:

 

I have a table in which I have a product key, date filter, stages, and cost to it. The stages change from one to other at certain dates and not all dates. What I want to do is populate the last nonblank value of a stage for a given product key(given the sorting of Date is Ascending for each Product key). So my table looks like this:

Product KeyDateStageCost
xyz1/8/2020borrow10
xyz1/9/2020 10
xyz1/10/2020paid10
xyz1/11/2020 10
xyz1/12/2020 10
xyz1/13/2020 10
abc1/9/2020borrow12.5
abc1/10/2020 12.5
abc1/11/2020unpaid12.5
abc1/12/2020 12.5
abc1/13/2020paid12.5

 

What i want is to update the previous stage for each product key(based on the fact that the date is ascending order), please note that the stages are simplified here, they can be as many as 10-12 different stages. Result table should be like:

 

Product KeyDateStageCost
xyz1/8/2020borrow10
xyz1/9/2020borrow10
xyz1/10/2020paid10
xyz1/11/2020paid10
xyz1/12/2020paid10
xyz1/13/2020paid10
abc1/9/2020borrow12.5
abc1/10/2020borrow12.5
abc1/11/2020unpaid12.5
abc1/12/2020unpaid12.5
abc1/13/2020paid12.5

 

Your help is really appreciated,

 

thanks,

Hello, would a simple fill down in Power Query work?

 

11097486_0-1615402891144.png

 

It works perfectly! Thank you!

Hi,

 

My table is getting created in PowerBI model itself and I dont have the same coming from the query. It is essentially a bigger challenge that I am trying to solve with this exercise- I will be tabulating this and assigning a variable to this table and use it in my next calculation, hence wanted to use DAX for this, please help!

I tried with CALCULATE but it doesn't work with string. I unfortunately wasn't able to find a solution...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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