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
Andreew14
Frequent Visitor

Lastnonblank date - calculated column for each category and date range

Hi everyone,

 

could anybody give me an advice how to create calculate column for lastnonblank date for each category and within the date range, please ?

 

I have a table where are dates, accounts and balance. Balance is available only for some dates. 

I need to calculate date, where the balance is not blank, but for each account separately. 

 

Example account "AAA" has balance in 29.1.2021 and 27.1.2021. 

So for date 31.1.2021 and account "AAA" there is a last non blank date : 29.1.2021

But for date 28.1.2021 and account "AAA" there is a last non blank date 27.1.2021

 

 

A need this DAX as CALCULATED COLUMN - not measure.

I would be very greatful if someone could help.

 

lastnonblank.jpg

6 REPLIES 6
rfigtree
Resolver III
Resolver III

If not solved already try.

 

=CALCULATE(max(Table1[date]),FILTER(all(Table1),Table1[acct]=EARLIER(Table1[acct])))

 

rfigtree_0-1612249813212.png

 

amitchandak
Super User
Super User

@Andreew14 , Try a new measure like

 

calculate(max(Table[Date]), not(isblank(Table[balance])), allexcept(Table, Table[Account]))

Hi amitchandak,

 

thank you for replying.

But it not working properly (for account "AAA" in 28.1.2021 , there should be last nonblank date 27.1.2021 and not 29.1.2021).

 

I need it as calculated column. Could you help?

error.jpg

@Andreew14 , try like

 

calculate(max(Table[Date]), not(isblank(Table[balance])), allexcept(Table, Table[Account]), filter(Table, [Date] <=max(Table[Date])))

 

or

 

calculate(max(Table[Date]), allexcept(Table, Table[Account]), filter(Table, [Date] <=max(Table[Date]) &&  not(isblank(Table[balance]))))

 

 

None of two mentioned measures is working. 

Only dates where is a any balance are showing.  Where is no balance , measures are empty. 

 

erro2.jpg

 

@Andreew14 ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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.

Top Solution Authors