Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Simple LASTNONBLANK DAX question

$
0
0

I am a DAX beginner, and I am trying to get to grips with what I think is a very simple, common semi-additive scenario. I think I must be missing something quite fundamental so please bear with me!

I have an ACCOUNT table which has a 1 to many relationship with an ACCOUNT_BALANCE table. There is a separate date dimension, which has a 1 to many relationship with the ACCOUNT_BALANCE table.

All I am trying to do is calculate the latest balance date for each account. I have the following DAX query:

DEFINE
MEASURE
ACCOUNT[NUMBER OF BALANCES] = COUNTROWS(RELATEDTABLE(ACCOUNT_BALANCE))
MEASURE
ACCOUNT[LATEST BALANCE DATE] = LASTNONBLANK(DimDate[FullDate], COUNTROWS(RELATEDTABLE(ACCOUNT_BALANCE)))
EVALUATE
ADDCOLUMNS
(
	ACCOUNT,	"Number of Balances", ACCOUNT[NUMBER OF BALANCES],"Latest Balance Date", ACCOUNT[LATEST BALANCE DATE]
)

While the number of balances evaluates correctly, I just get blanks for the latest balance date.

I think I must be missing something quite fundamental about how DAX works in this type of scenario. Any pointers would be much appreciated.

Thanks,

Robert


Viewing all articles
Browse latest Browse all 14337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>