Forum Discussion
Mapping postcode to Easting/Northing set
I have a set of temprature data that is displayed in a regular grid for example a point is Easting 102500 Northing 587500. I want to work out what is the nearest postcode district to this point so i can report by county or region
This table Daily_Time_Series looks like this
Date Location Easting Northing Min Temp
| 01/01/00 | 102500-587500 | 102500 | 587500 | 2.09 |
| 02/01/00 | 102500-587500 | 102500 | 587500 | 3.91 |
| 03/01/00 | 102500-587500 | 102500 | 587500 | 3.74 |
| 04/01/00 | 102500-587500 | 102500 | 587500 | 1.71 |
The location data I have is by postocde district and contains the easting/northing of roughly the centre of the area. For example Postcode_District table is
Postcode Easting Northing
| AB1 | 391839 | 804005 |
| AB10 | 392991 | 804882 |
| AB12 | 393424 | 801375 |
| AB11 | 394446 | 805136 |
Essentially I need to calcuate for each row in the first table the following formula (roughly a sq error term)
Error:=( 'Daily Time Series data'[Easting]- Postcode_District[Easting])*( 'Daily Time Series data'[Northing]- Postcode_District[Northing])
and then return the value of postcode where the error is the smallest.
I understnad the principal of the calcuation but not the syntax. for each row of Daily Time Series i calcaute a table of these error terms by iterating the Postcode_District Table, and then find the min.
Any help greatly appreicated as tried 4 or 5 different ideas but none work
Mike
3 Replies
- v-chuncz-msftCommunity Support
- masplinImpactful Individual
Problem is its TOPN of a function across a whole table. I've tried using SUMMARIZE to create a table and apply my formula but doesn't work.
- masplinImpactful Individual
I've made a small amount of progress. This calcuated column correctly calcuates the smallest vlaue of my error term for each location in my original data set
=CALCULATE( MINX( SUMMARIZE( Postcode_District, Postcode_District[Postcode], Postcode_District[Easting], Postcode_District[Northing] ), (('Daily Time Series data'[Average of Easting]-Postcode_District[Easting])^2)+(('Daily Time Series data'[Average of Northing]-Postcode_District[Northing])^2) ) )Now I need to identify the row in my Postcode_District table that contained the easting/nohing combination that matches this number and retrun the Postcode_District[Postocde] value?
I tried this (without really understanding the syntax) and got a circular error.
=CALCULATE( VALUES(Postcode_District[Postcode]), TOPN( 1, SUMMARIZE( Postcode_District, Postcode_District[Postcode], Postcode_District[Easting], Postcode_District[Northing] ), (('Daily Time Series data'[Average of Easting]-Postcode_District[Easting])^2)+(('Daily Time Series data'[Average of Northing]-Postcode_District[Northing])^2), ASC ) )