Skip to main content
|

PowerPivotPro's FAQ Site

Go Search
  
PowerPivotPro's FAQ Site > The Great PowerPivot FAQ > Get the sum of values of the last month having data using LASTNONBLANK  

The Great PowerPivot FAQ: Get the sum of values of the last month having data using LASTNONBLANK

Title

Get the sum of values of the last month having data using LASTNONBLANK 

Answer

To create a measure that shows you the sum of values of the running month even when you have future data in your time dimension you have to use the function LASTNONBLANK. usage: LASTNONBLANKDATE (,[]) Returns the last date in the current context for the specified Date_Column. When the optional argument, expression, is supplied, the function returns the last date where the conditions in the expression return a non-blank value. So using the expression you need to return null/blank where no related data is available like: LASTNONBLANK(DATEFIELD, countrows(RelatedTable(FACTTABLE))) We count the rows of the fact table related to the datefield supplied. When no rows are counted the last date supplying rows is the lastnonblank. Sample of usage measure Total Last month of year: =CALCULATE(sum(‘FactInternetSales’[OrderQuantity]), DATESMTD( LASTNONBLANK(‘DimDate’[FullDateAlternateKey], countrows(RelatedTable(‘FactInternetSales’)))) ,ALL(‘DimDate’)) (Use the ALL in CTP3 only).

Client/Server

Client 

Topic

F - Calculations (DAX) 

Purpose

Information 

Answered?

Yes 

Contributor

Kasper de Jonge 

Título

 

Resposta

 

Frage

 

Antwort

 

preRTM

 
Attachments
Created at 1/17/2010 3:27 AM  by Kasper de Jonge 
Last modified at 1/17/2010 3:27 AM  by Kasper de Jonge