https://github.com/deddyandri/tomanbikeshare
SQL & Power BI project about helping Toman Bike Share to understand if increasing prices next year is possible
https://github.com/deddyandri/tomanbikeshare
powerbi sql
Last synced: 5 months ago
JSON representation
SQL & Power BI project about helping Toman Bike Share to understand if increasing prices next year is possible
- Host: GitHub
- URL: https://github.com/deddyandri/tomanbikeshare
- Owner: deddyandri
- Created: 2025-02-13T05:10:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-30T01:51:09.000Z (about 1 year ago)
- Last Synced: 2025-06-11T17:57:37.212Z (about 1 year ago)
- Topics: powerbi, sql
- Homepage:
- Size: 730 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
from now on, I will show my work process in the readme, so that everyone can understand better.
unless it's a long process, then I'll make it in pdf
## the final result of power bi visualization is

recomendation based on calculation of sum of riders, sum of revenue, sum of profit , and average of price


# TomanBikeShare
# Requirements :
1. Hourly revenue analysis
2. Profit and Revenue Trends
3. Seasonal Revenue
4. Rider Demographics
# process steps
first open SQL server management studio
we start with create database by right click on folder Databases then click New database

on Database name, filled with name bike_data

now you could see bike_data Databases

we can now add tabel to the databases ,
right click on bike_data, then Task, and Import flat file

windows will appear, then click just next
then click browse to find the file
the file name is in the attachment on this github, you can download it
first we enter a file called bike_share_yr_0.csv
then click next
a preview of the data will appear,
to note here, click uncheck at the bottom of the preview table

modify column will appear, we can change the data type and column name, then click next,
after the summary is shown, click finish
the next step is to click refresh located at the top

a table called dbo.bike_share_yr_0 has been inserted into the bike_data database.

To view the table contents, right-click on the table you want to view. then click select top 1000 rows

the result is the content of the table (1000 rows) and the SQL query

#### we can add 2 other files namely dbo.bike_share_yr_1 and dbo.cost_table
#### in the way that I have described above
#### after refreshing, the 3 files have been entered into the bike_data databases.

we will now increase the font size of the script display and result display
The method is, on the main menu, select tools, then options
#### an Options window will appear

#### choose Environment then Fonts and Colors

#### on the "show settings for", choose Grid Results, we can change Font and size,
#### I prefer using Arial font with size 12, then OK

to be able to see the changes, the application must be restarted first
we go back to table dbo.bike_share_yr_0
now we block all the sql coding, to be deleted
press Delete key on the keyboard

we will merge the two files bike_share_yr_0 and bike_share_yr_1, using the union function
```sql
select * from bike_share_yr_0
union
select * from bike_share_yr_1
```
We can see the result at the bottom right of the result query, where the number of rows is 34,758.

we will see the contents of the cost_table query

we will join the table previously formed with the cost_table query,
here we see the cost table can join the main table through the yr column
we will join using the left join function and CTE (Common Table Expression)
We can see the combined table between bike_share_yr_0 and yr_1 as follows :

```sql
with cte as(
select * from bike_share_yr_0
union
select * from bike_share_yr_1)
-- Main Query
select * from cte a
left join cost_table b
on a.yr = b.yr
```
The result is that there are additional new columns, namely price and COGS, to the right of the main column.

we will use just some columns,
```sql
with cte as(
select * from bike_share_yr_0
union
select * from bike_share_yr_1)
select
dteday,
season,
a.yr,
weekday,
hr,
rider_type,
riders,
price,
COGS
from cte a
left join cost_table b
on a.yr = b.yr
```
the results are

we also add revenue column which is the multiplication of the rider column by the price
and Profit Column which is multiplication of rider x price minus COGS

```sql
with cte as(
select * from bike_share_yr_0
union
select * from bike_share_yr_1)
select
dteday,
season,
a.yr,
weekday,
hr,
rider_type,
riders,
price,
COGS,
riders*price as Revenue,
riders*price - COGS as Profit
from cte a
left join cost_table b
on a.yr = b.yr
```
the final result are

we will use this query to make a visualization in power BI.
In order for this query to connect with Power BI, we need to know the server type and server name.
The first step is:
at the top of Object Explorer menu, click server name, then right click, choose connect

we can identify its server name, my server name is HOME-PC1 , block and copy the server name

now open the microsoft power bi desktop application
on menu click get data, then Server Name
we then fill in server name and database name

then click Advanced Option to fill in SQL Statement
we then open SQL SMS to copy the final query

then paste it on SQL Server database windows which is in power bi

then click OK
then the windows will appear again, click connect, Then OK

now we start move on to microsoft power BI desktop
after the process of importing sql query to power BI,
in the power BI desktop application there will be a window that contains the sql query that we have created.

click Load
We can check whether the query has been entered, by clicking on the table view in the left menu of the Power BI desktop.

we now start making the visualization
I will not explain the visualization process in power BI, but you can see the file in the attached file.
there is a slight change to the revenue formula, for that we can change it through the Power BI desktop.
there is a Transform data on top of power BI menu

data transform windows will appear

on the right side, there is APPLIED STEP menu, click on gear icon beside the text is written Source

There will be a SQL server database window, in the section labeled “SQL statement”, we will change the sql code

we will change this code

become

then click OK
on the top left corner, click Close&Apply