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
jmcph
Helper III
Helper III

Value before the firstnonblankvalue

Hi, i am trying to compute for the value before the firstnonblankvalue. I am computing for Beginning Inventory of a particular model,  my date looks like this: 

 

Date                       Particulars                       Item                            Qty

9/30/2020               InvEnd                              Item 1                          100

10/1/2020               InvEnd                              Item 1                          90

10/31/2020             InvEnd                              Item 1                          50

 

My filters based on Calendar date.

 

Since the ending inventory of a particular day will be the beginning inventory of the next day i didnt include a separate beginning inventory column. My current DAX on the beginning inventory looks like this ( for October Beginning Inventory)

 

Inv = FIRSTNONBLANKVALUE( 'Calendar'[Date] ,

Sumx( Inventory, if ( Inventory[Particulars] = "End", Inventory[Amount] , 0)
)
 
then i used Calculate to get the 9/30/2020 value by:
 
Beginnng Inv = 
Calculate( [Inv] , Dateadd( 'Calendar'[Date] , -1 , Day))
 
But makes me think, that my DAX wont work if there is no data encoded for 9/30/20. What if the last inventory was made 9/29/20?
 
I hope you can help me and i make my question clear! 
 
Cheers!  
2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @jmcph ,

 

Sorry, not very clear.

 

Do you want to put the first non-blank value (100) in the Inventory table into the row of the day before the corresponding date in the calendar table?


FIRSTNONBLANKVALUE has already filtered out non-blank values, so if the value on September 30 is blank, it will continue to find the first non-blank value.

 

 

 

Best Regards,

Stephen Tao

 

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

@jmcph , Try a new column like


new column =
calculate(lastnonblankvalue([Date], sum(Table[Qty])), filter(Table, [item] =earlier([item]) && [Date] <earlier([Date])))

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.