👉 Calculate distance between 2 points using Spherical Law of Cosines formula
The measure Distance in Miles, calculates the distance in miles between one designated starting location and multiple destination locations using the Spherical Law of Cosines formula.
*Thanks to various examples on the internet that had explanations in detail on how to calculate the distance between 2 points and then visualize it on a Map Chart .
In this video, we will use Power BI Desktop to create a report page.
1. We first load the Places.csv file into Power BI Desktop.
2. This table has Latitude and Logitude values as well.
3. By using the relevant column values from the 'Places table', we will create two additonal tables: 'Countries ' and 'From City'
4. We will then create a relationship between those tables in the Model View.
5. We will briefly review the problem statement and then step by step , we will write the DAX code .
6. Two measure will be created: one is to find the *distance between 2 points using Latitude and Longitude values and the other measure is a simple Description measure.
7. Finally we will create a report page that has 2 visuals. Table and a Map Chart. The values will change dynamically based on the user selections.
In this example we will use 'Places.csv dataset' (dated 6/20/2023) from Tidytuesday R Repository
FYI: Periodically we will create additional report pages & add more videos using the same dataset so that we will create a dedicated playlist for all these videos.
2 Datasets:
https://github.com/rfordatascience/ti...
https://github.com/rfordatascience/ti...
More datasets @Tidytuesday R
https://github.com/rfordatascience/ti...
TIMESTAMPS
00:00 Copy the new dataset url and then load the Places.csv file using Web option in PBI Desktop
00:25 Problem Statement ; how to calculate distance between 2 places using Latitude and Longitude
01:00 Model View (discuss relationships)
01:17 Creating 2 tables using create table options in the Table view
02:12 Create the needed relationships in the Model VIew
03:29 Change the data category type of Latitude and Longitude
03:50 Create a new measure to calculate distance between 2 places
04:44 Create a report page that has slicers, Table Visual and a Map Visual
06:41 Create a Description measure
07:24 Use Filters option and select TopnN and apply Bottom filter on both Table and map visual
08:08 On the report page, make slicer selections and view the visuals.
09:43 Recap and conclusion