Forum Discussion
Lycias
Jul 12, 2023Brass Contributor
Excel look up values and select most recent year
Good day,
I want a formula that look-up an indicator in could D, for a specific age group in column F for a specific country using the country ISO code in column H, then retrieves the most recent value using year in column J, and the indicator value is in column L. Please see attached dummy data.
Thanks,
Lycias
The query will be many magnitudes faster if you use the Usage table (which has already aggregated the usage data), rather than trawling through a massive number of records.
If you are not worried about whole month, this is a simple query for each 30d period
Usage | where TimeGenerated between ( startofmonth(now(),-3).. endofmonth(now(),-1) ) | summarize GBday = sum(Quantity)/1000 by bin(TimeGenerated, 30d)
Go to Log Analytics and run query
TimeGenerated GBday 2021-03-02T00:00:00Z 516.7549875128676 2021-05-01T00:00:00Z 1060.202420264586 2021-04-01T00:00:00Z 520.8967723819818 2021-05-31T00:00:00Z 34.28783515715939 2021-01-31T00:00:00Z 2.716749379860088 or to have whole months, maybe this is a start:
union ( Usage | where TimeGenerated between ( startofmonth(now(),-3).. endofmonth(now(),-3) ) | summarize GBmonth=sum(Quantity)/1000 , min(TimeGenerated), max(TimeGenerated), month = datetime_part("month", min(TimeGenerated)) ), ( Usage | where TimeGenerated between ( startofmonth(now(),-2).. endofmonth(now(),-2) ) | summarize GBmonth=sum(Quantity)/1000 , min(TimeGenerated), max(TimeGenerated), month = datetime_part("month", min(TimeGenerated)) ), ( Usage | where TimeGenerated between ( startofmonth(now(),-1).. endofmonth(now(),-1) ) | summarize GBmonth=sum(Quantity)/1000 , min(TimeGenerated), max(TimeGenerated), month = datetime_part("month", min(TimeGenerated)) )
GBmonth min_TimeGenerated max_TimeGenerated month 519.4717368927277 2021-03-01T00:00:00Z 2021-03-31T23:00:00Z 3 520.8967723819818 2021-04-01T00:00:00Z 2021-04-30T23:00:00Z 4 1094.4902554217456 2021-05-01T00:00:00Z 2021-05-31T23:00:00Z 5
13 Replies
Sort By
The formula is a bit more complicated since all values in your sample worksheet are text.
See the attached version.
- LyciasBrass ContributorThanks, Hans. Is it possible to have this as one formula that I can use in a column in another sheet to pull this value? I just want the data value in one column for all countries?