Forum Discussion

KW123's avatar
KW123
Helper V
3 years ago

First non null value

I have data that is sorted by report month.  Here is a screen shot for one Customer ID.  Each Customer can have multiple accounts, but here is one account example: 


What I need to extract is the last $ value (current balance) before the customer closed their account. In this example, it would be $xxx,xxx on report month 04/30/2022.  I have created a duplicate current balance column with null values to replace the $0 so that I could do a DAX which would be something like "The first non null value" 

I can't use FIRSTNONBLANK as it could be the case that the last $ in the account was not necessarily their highest/lowest $.  

Is there an easy way to get this? 
Thank you! 

7 Replies

  • I think you can use

    Last Balance =
    LASTNONBLANKVALUE ( 'Table'[Report Month], SUM ( 'Table'[Duplicate balance] ) )
    
    • KW123's avatar
      KW123
      Helper V

      johnt75 

      I have tried using this one: 

      Last Balance =
      var i = SELECTEDVALUE('Query1'[MemberNumber])
      var d2 = CALCULATE(LASTNONBLANKVALUE('Query1'[Duplicate current balance],SELECTEDVALUE('Query1'[Duplicate current balance])),all('Query1'),'Query1'[Duplicate current balance] <>BLANK(),'Query1'[MemberNumber]=i)
      return d2

      But it returns the largest $ amount in the customers account history, instead of whatever the last $ amount was before they closed their account. 

      The DAX you suggested returned blank on the report.  As a column, it added up the entirety of the account balances.  I switched the [reportmonth] to closeddate and that didn't seem to work either (just returned blank) 
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi KW123 ,

        In order to get a better understanding on your requirement and give you a suitable solution, please provide some fake data in your table 'Query1' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

        How to upload PBI in Community

        Best Regards