---
title: "RETAIL STORE SALES DASHBOARD"
output:
flexdashboard::flex_dashboard:
theme: cosmo
orientation: row
vertical_layout: scroll
source_code: embed
social: ["menu"]
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(plotly)
library(rpivotTable)
data <- read.csv("Details.csv")
data1 <- read.csv("Orders.csv")
data_full <- data %>% inner_join(data1)
data_full$Order.Date <- dmy(data_full$Order.Date)
```
Row
-----------------------------------------------------------------------
### Total Amount
```{r}
valueBox(paste(sum(data_full$Amount)), color = "red",
icon = "ion-arrow-graph-up-right")
```
### Total Profit
```{r}
valueBox(paste(sum(data_full$Profit)), color = "red",
icon = "ion-arrow-graph-up-right")
```
### Total Quantity
```{r}
valueBox(paste(sum(data_full$Quantity)), color = "red",
icon = "ion-ios-list-outline")
```
Row
-----------------------------------------------------
### Total Amount By State
```{r}
theme_set(theme_classic())
state <- data_full %>%
select(State,Amount)
state$State <- factor(state$State)
state %>%
group_by(State) %>%
summarise(amount = sum(Amount)) %>% data.frame() %>%
filter(amount > mean(amount)) %>%
ggplot(aes(fct_reorder(State,amount), amount, label = amount))+geom_col(fill = "orange")+ geom_text(hjust = 2, size = 7)+
coord_flip()+
theme(legend.position = "none")+
labs(x = "State", y ="Amount")+theme(axis.text.y = element_text(face = "bold", colour = "black", size = 10), axis.text.x = element_text(face = "bold", colour = "black", size = 10))
```
### Total Quantity by Category
```{r}
data_full %>%
select(Quantity,Category) %>%
plot_ly(labels = ~Category,
values = ~Quantity) %>%
add_pie(hole = 0.4)
```
### Total Amount by Customer Name
```{r}
data_full %>%
select(Amount, CustomerName) %>%
filter(Amount > 2900) %>%
ggplot(aes((fct_reorder(CustomerName,Amount)), Amount, fill = CustomerName, label = Amount))+
geom_col()+ geom_text(hjust = 3, size = 5)+
theme(
axis.text.x = element_text(face = "bold", colour = "black"), legend.position = "none",
axis.text.y = element_text(face = "bold", colour = "black", size = 10)
)+labs(x = "Customer Name")+coord_flip()
```
Row
--------------------------------------------------------------------------------
### Total Profit by Month
```{r}
data_full %>% select( Order.Date,Profit) %>%
mutate(month = month(Order.Date, label = TRUE)) %>%
group_by(month) %>%
summarise(total_profit= sum(Profit)) %>%
ggplot(aes(month, total_profit, fill = factor(sign(total_profit)), label = total_profit))+geom_col()+
scale_fill_manual(values = c("red","orange"))+theme(legend.position = "none")+
labs(y = "Profit",x = "Month")+theme(
axis.text.x = element_text(face = "bold", color = "black"),
axis.text.y = element_text(face = "bold", colour = "black")
)+geom_text(hjust = 0.5, color = "black", size = 4)+coord_flip()
```
### Total Quantity by Payment Mode
```{r}
data_full %>%
select(Quantity,PaymentMode) %>%
plot_ly(values =~ Quantity,
labels = ~PaymentMode) %>%
add_pie(hole = 0.3)
```
### Total Profit By Sub Category
```{r}
data_full %>%
select(Sub.Category, Profit) %>%
group_by(Sub.Category) %>%
summarise(total_sub = sum(Profit)) %>%
filter(total_sub>0) %>%
ggplot(aes(fct_reorder(Sub.Category,total_sub),total_sub ,label = total_sub, fill = Sub.Category))+geom_col()+
geom_text(hjust = 2, size = 5)+
theme(
axis.text.x = element_text(face = "bold", colour = "black"), legend.position = "none",
axis.text.y = element_text(face = "bold", colour = "black", size = 10)
)+labs(x = "Sub Category", y = "Profit")+coord_flip()
```
Row
-------------------------------------------------------------------
### Profit Per Quarter
```{r}
p <- data_full %>% select(Category,Order.Date, Profit) %>%
mutate(quarter = quarter(Order.Date)) %>%
group_by(quarter) %>%
summarise(profit_quarter = sum(Profit)) %>%
ggplot(aes(quarter, profit_quarter, label = profit_quarter, fill = quarter))+geom_col()+
labs(y = "Profit", x = "Quarter")
p+geom_text(hjust = 0.5, size = 5, color = "red")+coord_flip()+theme(legend.position = "none")
```
### Amount Traded Weekdays
```{r}
data_full %>% select(Category,Order.Date, Amount) %>%
mutate(weekday = wday(Order.Date, label = TRUE)) %>%
group_by(weekday) %>%
summarise(Amount_traded = sum(Amount)) %>%
ggplot(aes(weekday, Amount_traded, fill = weekday, label = Amount_traded))+geom_col()+
labs(y = "Amount Traded", x ="Day of the Week")+theme(legend.position = "none")+
geom_text(vjust = 2, size = 5)
```