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 August 31st. Request your voucher.

Reply
Varan_15
Helper III
Helper III

create missing data using previous non blank date value

Hi All,

 

I have customer wise sales table which is contain few blank dates and empty values , I have to consider last non blank value on same customer level kindly help.

 

actual data:

dateholiday checkcustomer IDSales
24/03/2024 0:00weekday1100016350
25/03/2024 0:00weekday1100016345
26/03/2024 0:00weekday1100016345
27/03/2024 0:00weekday  
28/03/2024 0:00weekday  
29/03/2024 0:00Weekend  
30/03/2024 0:00Weekend  
31/03/2024 0:00weekday1100016345
01/04/2024 0:00weekday1100016345
02/04/2024 0:00weekday1100016345
03/04/2024 0:00weekday1100016345
04/04/2024 0:00weekday1100016345
05/04/2024 0:00Weekend  
06/04/2024 0:00Weekend  

 

expected result:

 

need.PNG

 

highlighted color data is refering last date of non blank value and customer as well. Kindly suggest how to create measure/column

 

Thanks in advance 

1 ACCEPTED SOLUTION

@Varan_15 ,

 

Create two columns using

 

Filled Customer ID =
VAR CurrentDate = 'Table'[date]
RETURN
IF(
ISBLANK('Table'[customer ID]),
CALCULATE(
LASTNONBLANK('Table'[customer ID], 1),
FILTER(
'Table',
'Table'[date] < CurrentDate
)
),
'Table'[customer ID]
)

 

And

Filled Sales =
VAR CurrentDate = 'Table'[date]
VAR CurrentCustomer = 'Table'[Filled Customer ID]
RETURN
IF(
ISBLANK('Table'[Sales]),
CALCULATE(
LASTNONBLANK('Table'[Sales], 1),
FILTER(
'Table',
'Table'[Filled Customer ID] = CurrentCustomer &&
'Table'[date] < CurrentDate
)
),
'Table'[Sales]
)

 

Attaching PBIX with your sample date




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

6 REPLIES 6
rajendraongole1
Super User
Super User

Hi @Varan_15 - you can fill the blank values in power query editor with fill down transformation. 

 

rajendraongole1_0-1720693760871.png

 

Or you can try with below measure too

 

rajendraongole1_1-1720694253931.png

LastNonBlankSales1 =
CALCULATE(
    LASTNONBLANKVALUE(
        HCD[date],
        CALCULATE(MAX(HCD[Sales]))
    ),
    ALLEXCEPT(HCD, HCD[Customer ID])
)

 

Hope it works

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





@rajendraongole1 ,

 

Thanks for the update.

 

fill will not workout becasue in the original table there is dates are missing hence i'm using calendar table to full month completion.

for the measure which you updated it's capturing same value for all the days.. if you see (march 24 will be 350 sales),

 

Plase note : as per monthly date if any blank in middle dates it should take previous value that's requirement

 

Thanks

bhanu_gautam
Super User
Super User

@Varan_15 , Create a new calculated columns using

 

LastNonBlankSales =
VAR CurrentDate = SalesData[date]
VAR CurrentCustomer = SalesData[customer ID]
RETURN
CALCULATE(
LASTNONBLANK(SalesData[Sales], SalesData[date]),
FILTER(
SalesData,
SalesData[customer ID] = CurrentCustomer &&
SalesData[date] <= CurrentDate &&
NOT(ISBLANK(SalesData[Sales]))
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam ,

 

Thanks for your update, I couldn't able to enter lastnonblank second field "date" as it's considering only one field 

 

LastNonBlankSales =
VAR CurrentDate = SalesData[date]
VAR CurrentCustomer = SalesData[customer ID]
RETURN
CALCULATE(
LASTNONBLANK(SalesData[Sales], SalesData[date]),
FILTER(
SalesData,
SalesData[customer ID] = CurrentCustomer &&
SalesData[date] <= CurrentDate &&
NOT(ISBLANK(SalesData[Sales]))
)
)

 

(sales[date]) can't able to add. please suggest

@Varan_15 , You can achieve it in Power Query also

 

bhanu_gautam_1-1720693602689.png

Just click on Fill and select down it will get it done make sure correct column is selected

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@Varan_15 ,

 

Create two columns using

 

Filled Customer ID =
VAR CurrentDate = 'Table'[date]
RETURN
IF(
ISBLANK('Table'[customer ID]),
CALCULATE(
LASTNONBLANK('Table'[customer ID], 1),
FILTER(
'Table',
'Table'[date] < CurrentDate
)
),
'Table'[customer ID]
)

 

And

Filled Sales =
VAR CurrentDate = 'Table'[date]
VAR CurrentCustomer = 'Table'[Filled Customer ID]
RETURN
IF(
ISBLANK('Table'[Sales]),
CALCULATE(
LASTNONBLANK('Table'[Sales], 1),
FILTER(
'Table',
'Table'[Filled Customer ID] = CurrentCustomer &&
'Table'[date] < CurrentDate
)
),
'Table'[Sales]
)

 

Attaching PBIX with your sample date




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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