Hidden functionality of LOOKUPVALUE function

Despite described was not noticed a useful trick in functionality of the LOOKUPVALUE function – in contrast to LOOKUP in SSRS (and in probably many other systems) it returns a distinct selection of found values if there is only one value. From MSDN:

If multiple rows match the search values and in all cases result_column values are identical then that value is returned. However, if result_column returns different values an error is returned.

In the next two scripts Date table is filtered by the same Financial Year:

EVALUATE
SUMMARIZE(
 FILTER('Date', 'Date'[Financial Year] = 
 FORMAT(IF(VALUE(RIGHT("201410",2))>6, VALUE(LEFT("201410", 4)), VALUE(LEFT("201410", 4))-1), "General Number")
 &"-"&
 FORMAT(IF(VALUE(RIGHT("201410",2))>6, VALUE(LEFT("201410", 4))+1, VALUE(LEFT("201410", 4))), "General Number"))
 , 
 [Year Month]
)


EVALUATE
SUMMARIZE(
 FILTER('Date', 'Date'[Financial Year] = LOOKUPVALUE('Date'[Financial Year], [Year Month], VALUE("201410")))
 , 
 [Year Month]
)

 

Advertisements

About fdtki

Sr. BI Developer | An accomplished, quality-driven IT professional with over 16 years of experience in design, development and implementation of business requirements as a Microsoft SQL Server 6.5-2014 | Tabular/DAX | SSAS/MDX | Certified Tableau designer
This entry was posted in programming and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s