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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Marwen89
Frequent Visitor

Copy lastnonblank value for future date

Hi, 

I want to copy lastnonblank value for future date. 

For exemple:

Lastnonblank value 100 at 22 February 2022,

I want to copy it for all periode >this date. 

How to do this with Dax? 

 

Any suggestions please?

Thanks

 

1 ACCEPTED SOLUTION

Hi @Marwen89 ,

 

Power BI doesn't support you to transform the existing column by Dax. You need to create a new column by Dax to achieve your goal.

Try this code to create calculated columns.

Fill Down CANADA = 
VAR _Last = CALCULATE(LASTNONBLANKVALUE('Table'[Date], SUM('Table'[CANADA])), ALLSELECTED())
return
IF('Table'[CANADA] = BLANK(),_last,'Table'[CANADA])
Fill Down EUROPE = 
VAR _Last = CALCULATE(LASTNONBLANKVALUE('Table'[Date], SUM('Table'[EUROPE])), ALLSELECTED())
return
IF('Table'[CANADA] = BLANK(),_last,'Table'[EUROPE])

Result is as below.

1.png

 

Best Regards,
Rico Zhou

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

6 REPLIES 6
Marwen89
Frequent Visitor

Here it is, i want to copy lastnonblank value for date in future like this exemple.  

IMG_20220224_101219.jpg

Hi @Marwen89 ,

 

Firstly, make sure there are future dates in your data model. We need actual data to calculate or do some transform in Power BI.

If your table looks like as below. Sort your [Date] column by ascending. Then try Fill Down  function.

1.png

Result is as below.

1.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your response, 

I need it on Dax,

 

 

Hi @Marwen89 ,

 

Power BI doesn't support you to transform the existing column by Dax. You need to create a new column by Dax to achieve your goal.

Try this code to create calculated columns.

Fill Down CANADA = 
VAR _Last = CALCULATE(LASTNONBLANKVALUE('Table'[Date], SUM('Table'[CANADA])), ALLSELECTED())
return
IF('Table'[CANADA] = BLANK(),_last,'Table'[CANADA])
Fill Down EUROPE = 
VAR _Last = CALCULATE(LASTNONBLANKVALUE('Table'[Date], SUM('Table'[EUROPE])), ALLSELECTED())
return
IF('Table'[CANADA] = BLANK(),_last,'Table'[EUROPE])

Result is as below.

1.png

 

Best Regards,
Rico Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Marwen89 , Try a measure like

var _last = calculate(lastnonblankvalue(Date[Date], Sum(Table[Value])), allselected())
return
if(max(Date[Date]) >= maxx(allselected(date), date[date]), _last, Sum(Table[Value]))

VahidDM
Super User
Super User

Hi @Marwen89 

 

Can you post sample data as text and expected output?
Not enough information to go on;

please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
4. Relation between your tables

Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors