├── README.md ├── Sales Insight Dashboard.pdf ├── Sales Insight.pbix ├── Sales_db_Initial_Insights.sql ├── db_dump_version_2_main.sql └── db_dump_without_ProfitMarginColumns.sql /README.md: -------------------------------------------------------------------------------- 1 | # Sales Insights Using PowerBI and SQL 2 | 3 | ## Problem Statement: 4 | AtliQ hardware, a brick and mortar business specializing in hardware goods, is facing challenges in understanding and analyzing its sales trend. The current lack of visibility into the sales data hinders the business's ability to make informed decisions and take proactive measures to drive growth. Without a comprehensive understanding of the sales trend, AtliQ hardware struggles to identify patterns, anticipate customer demand, optimize inventory, and tailor marketing strategies effectively. As a result, the business is unable to capitalize on potential growth opportunities and achieve its revenue goals. To overcome these obstacles, AtliQ hardware recognizes the need to implement a solution that provides a clear and insightful view of the sales trend, enabling data-driven decision-making and facilitating strategic actions to increase revenue and improve overall performance. 5 | 6 | ## Solution Approach: 7 | 8 | To address the problem statement, the following approach was used: 9 | 10 | ### * Data Import and Initial Analysis: 11 | The sales data was provided in a SQL dump file, which was imported into a SQL database. Initial insights were drawn from the data using SQL queries and analysis techniques to gain a preliminary understanding of the sales trend. 12 | 13 | ### * Connecting SQL Database to Power BI: 14 | The SQL database was connected to Power BI, establishing a live connection or importing the necessary data tables into Power BI. 15 | 16 | ### * Data Modeling and Relationship Creation: 17 | Data modeling was performed within Power BI to create relationships between the relevant tables in the SQL database. This step ensured that the data could be properly analyzed and visualized. 18 | 19 | ### * Data Cleaning and Transformation: 20 | Power BI's data transformation features, such as Power Query, were utilized to clean and transform the data. Irrelevant entries, duplicates, and inconsistencies were removed or resolved, ensuring the data was accurate and reliable. 21 | 22 | ### * Dashboard Creation - Key Insights: 23 | The first type of dashboard, "Key Insights," was created to provide an overview of the sales trend. This dashboard focused on presenting high-level metrics, such as total sales, top-selling products, sales by region, and sales by time period. Visualizations like charts, graphs, and KPIs were used to convey the key insights effectively. 24 | 25 | ### * Dashboard Creation - Profit Analysis: 26 | The second type of dashboard, "Profit Analysis," aimed to provide in-depth insights into the profitability of AtliQ hardware goods. This dashboard included visualizations and calculations related to profit margins, cost analysis, and product profitability. It allowed users to identify profitable products, assess cost effectiveness, and optimize pricing strategies. 27 | 28 | ### * Dashboard Creation - Performance Insights: 29 | The third type of dashboard, "Performance Insights," focused on analyzing the performance of AtliQ hardware goods. This dashboard provided visualizations and metrics related to sales performance, sales growth, customer segmentation, and market share. It enabled users to track performance trends, identify growth opportunities, and make data-driven decisions. 30 | 31 | Each dashboard was designed to be interactive, allowing users to filter and drill down into specific dimensions or time periods of interest. 32 | 33 | ## Expected Outcome: 34 | By implementing the above solution approach, AtliQ hardware expects to achieve the following outcomes: 35 | 36 | * Enhanced Data Analysis: The connection between the SQL database and Power BI enables real-time or near-real-time analysis of the sales trend. The solution provides users with the ability to explore and analyze data more efficiently, leading to better insights and understanding. 37 | 38 | * Improved Decision Making: The creation of the three dashboards (Key Insights, Profit Analysis, and Performance Insights) equips users with a comprehensive view of the sales trend from different perspectives. This enables informed decision making, such as identifying profitable products, optimizing pricing strategies, and targeting specific customer segments. 39 | 40 | * Increased Efficiency: By utilizing Power BI's data transformation features, data cleaning and transformation tasks are streamlined. This saves time and effort, allowing users to focus more on analyzing the data and extracting valuable insights. 41 | 42 | * Revenue Growth: With the ability to access key insights, analyze profitability, and monitor performance effectively, AtliQ hardware anticipates achieving a revenue growth of at least 7% in the next quarter. The data-driven decision making facilitated by the Power BI dashboards contributes to identifying growth opportunities and implementing effective strategies. 43 | 44 | Overall, this solution approach leverages the power of SQL and Power BI to provide a robust data analysis and visualization solution, empowering AtliQ hardware to make informed decisions and drive revenue growth. 45 | -------------------------------------------------------------------------------- /Sales Insight Dashboard.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shantamgarg24/Sales-Insights-Using-PowerBI-and-SQL/02b0d92bd8e8b18eb121b894b74ed4d8535f7b0e/Sales Insight Dashboard.pdf -------------------------------------------------------------------------------- /Sales Insight.pbix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shantamgarg24/Sales-Insights-Using-PowerBI-and-SQL/02b0d92bd8e8b18eb121b894b74ed4d8535f7b0e/Sales Insight.pbix -------------------------------------------------------------------------------- /Sales_db_Initial_Insights.sql: -------------------------------------------------------------------------------- 1 | -- Use sales database 2 | use sales; 3 | 4 | -- 1)Checking the no. of records in each table: 5 | 6 | SELECT COUNT(*) 7 | FROM customers; 8 | -- result: 38 records 9 | 10 | SELECT COUNT(*) 11 | FROM date; 12 | -- result: 1126 records 13 | 14 | SELECT COUNT(*) 15 | FROM markets; 16 | -- result: 17 records 17 | 18 | SELECT COUNT(*) 19 | FROM products; 20 | -- result: 279 records 21 | 22 | SELECT COUNT(*) 23 | FROM transactions; 24 | -- result: 150283 records 25 | 26 | -- 2)Checking the transactions table: 27 | 28 | SELECT * 29 | FROM transactions; 30 | 31 | -- looks like there are some records with sales amount -1 and currency as 'USD'. 32 | 33 | -- 3)Records which have sales less than 0: 34 | 35 | SELECT * 36 | FROM transactions 37 | WHERE sales_amount <= 0; 38 | 39 | -- 4)Number of records which are having sales amount less than 0: 40 | 41 | SELECT COUNT(*) 42 | FROM transactions 43 | WHERE sales_amount <= 0; 44 | 45 | -- result: 1611 records 46 | 47 | -- 5)Checking all the unique currency: 48 | 49 | SELECT DISTINCT(currency) 50 | FROM transactions; 51 | 52 | -- there seems to be two unique value with their duplicates. 53 | 54 | -- 6)Checking all the records with 'USD' currency: 55 | 56 | SELECT * 57 | FROM transactions 58 | WHERE currency in ('USD','USD\r'); 59 | 60 | -- records seems to be the duplicate records. 61 | 62 | -- 7)Checking the customers table: 63 | 64 | SELECT * 65 | FROM customers; 66 | 67 | -- 8)Checking the markets table: 68 | 69 | SELECT * 70 | FROM markets; 71 | 72 | -- there seems to be two markets namely 'New York' & 'Paris' which are based out of india. 73 | 74 | -- 9)Checking if there are any transaction from these markets: 75 | 76 | SELECT * 77 | FROM transactions 78 | WHERE market_code in ('Mark097','Mark999'); 79 | 80 | -- there are no such records. 81 | 82 | -- 10)Top 3 market according to the sales amount: 83 | 84 | WITH marketwise_sales_ranking 85 | as( 86 | SELECT market_code, 87 | markets_name, 88 | round(SUM(sales_amount)/1000000,2) as total_sales_in_millions, 89 | RANK() OVER(ORDER BY SUM(sales_amount)/1000000 desc) as sales_rank 90 | FROM transactions t 91 | INNER JOIN 92 | markets m 93 | on t.market_code = m.markets_code 94 | GROUP BY market_code 95 | ) 96 | SELECT * 97 | FROM marketwise_sales_ranking 98 | WHERE sales_rank<=3; 99 | 100 | -- result: Delhi NCR, Mumbai, Ahmedabad. 101 | 102 | -- 11)Top 3 customer according to the sales amount: 103 | 104 | WITH customerwise_sales_ranking 105 | as( 106 | SELECT t.customer_code, 107 | c.custmer_name, 108 | round(SUM(t.sales_amount)/1000000,2) as total_sales_in_millions, 109 | RANK() OVER(ORDER BY SUM(t.sales_amount)/1000000 desc) as sales_rank 110 | FROM transactions t 111 | INNER JOIN 112 | customers c 113 | on t.customer_code = c.customer_code 114 | GROUP BY t.customer_code 115 | ) 116 | SELECT * 117 | FROM customerwise_sales_ranking 118 | WHERE sales_rank<=3; 119 | 120 | -- result: Electricalsara stores, Electricalslytical, Excel stores. 121 | 122 | -- 12)Top 3 products sold according to the sales amount: 123 | 124 | WITH productwise_sales_ranking 125 | as( 126 | SELECT t.product_code, 127 | (CASE 128 | WHEN p.product_type is null THEN 'Unavailable' 129 | ELSE p.product_type 130 | END) as product_type, 131 | round(SUM(t.sales_amount)/1000000,2) as total_sales_in_millions, 132 | RANK() OVER(ORDER BY SUM(t.sales_amount)/1000000 desc) as sales_rank 133 | FROM transactions t 134 | LEFT JOIN 135 | products p 136 | on t.product_code = p.product_code 137 | GROUP BY t.product_code 138 | ) 139 | SELECT * 140 | FROM productwise_sales_ranking 141 | WHERE sales_rank<=3; 142 | 143 | -- result: Prod318, Prod316, Prod324. 144 | 145 | 146 | -- 13)Top 3 customer according to the sales amount in Delhi NCR market(Mark004), Mumbai(Mark002) and Ahmedabad(Mark003): 147 | 148 | with marketwise_customer_ranking 149 | as( 150 | SELECT t.market_code, 151 | m.markets_name, 152 | t.customer_code, 153 | c.custmer_name, 154 | round(SUM(t.sales_amount)/1000000,2) as total_sales_in_millions, 155 | RANK() OVER( PARTITION BY t.market_code ORDER BY SUM(t.sales_amount)/1000000 DESC) as sales_ranking 156 | FROM transactions t 157 | LEFT JOIN 158 | markets m 159 | on t.market_code = m.markets_code 160 | LEFT JOIN 161 | customers c 162 | on t.customer_code = c.customer_code 163 | GROUP BY t.market_code, t.customer_code 164 | ORDER BY t.market_code 165 | ) 166 | SELECT * 167 | FROM marketwise_customer_ranking 168 | WHERE market_code in ('Mark002','Mark003','Mark004') and sales_ranking<=3; 169 | 170 | -- 14)Top 3 product according to the sales amount in Delhi NCR market(Mark004), Mumbai(Mark002) and Ahmedabad(Mark003): 171 | 172 | with marketwise_product_ranking 173 | as( 174 | SELECT t.market_code, 175 | m.markets_name, 176 | t.product_code, 177 | CASE WHEN p.product_type is null THEN "Unavailable" ELSE p.product_type END as product_type, 178 | round(SUM(t.sales_amount)/1000000,2) as total_sales_in_millions, 179 | RANK() OVER( PARTITION BY t.market_code ORDER BY SUM(t.sales_amount)/1000000 DESC) as sales_ranking 180 | FROM transactions t 181 | LEFT JOIN 182 | markets m 183 | on t.market_code = m.markets_code 184 | LEFT JOIN 185 | products p 186 | on t.product_code = p.product_code 187 | GROUP BY t.market_code,t.product_code 188 | ORDER BY t.market_code 189 | ) 190 | SELECT * 191 | FROM marketwise_product_ranking 192 | WHERE market_code in ('Mark002','Mark003','Mark004') and sales_ranking<=3; 193 | 194 | -- 15) Top seasonal top 3 products: 195 | 196 | WITH seasonal_product_ranking 197 | as( 198 | SELECT seasons, 199 | t.product_code, 200 | (CASE 201 | WHEN p.product_type is null THEN "Unavailable" 202 | ELSE p.product_type 203 | END) as product_type, 204 | round(SUM(sales_amount)/1000000,2) as total_sales_in_millions, 205 | RANK() OVER(PARTITION BY seasons ORDER BY sum(sales_amount)/1000000 DESC) as sales_ranking 206 | FROM transactions t 207 | LEFT JOIN 208 | products p 209 | on t.product_code = p.product_code 210 | LEFT JOIN 211 | ( 212 | SELECT (CASE 213 | WHEN month_name in ("December","January","February") THEN "Winter" 214 | WHEN month_name in ("March","April","May") THEN "Spring" 215 | WHEN month_name in ("June","July","August") THEN "Summer" 216 | WHEN month_name in ("September","October","November") THEN "Fall" 217 | ELSE month_name 218 | END) as seasons, 219 | date 220 | FROM date 221 | ) as d 222 | on t.order_date = d.date 223 | GROUP BY t.product_code, seasons 224 | ) 225 | SELECT * 226 | FROM seasonal_product_ranking 227 | WHERE sales_ranking <=3; 228 | 229 | -- 16) Customer type wise top 3 products: 230 | 231 | WITH customer_typewise_product_ranking 232 | as( 233 | SELECT c.customer_type, 234 | t.product_code, 235 | (CASE 236 | WHEN p.product_type is null THEN 'Unavailable' 237 | ELSE p.product_type 238 | END) as product_type, 239 | round(sum(t.sales_amount)/1000000,2) as total_sales_in_millions, 240 | RANK() OVER(PARTITION BY c.customer_type ORDER BY sum(t.sales_amount)/1000000 DESC) as sales_ranking 241 | FROM transactions t 242 | LEFT JOIN 243 | customers c 244 | on t.customer_code = c.customer_code 245 | LEFT JOIN 246 | products p 247 | on t.product_code = p.product_code 248 | GROUP BY c.customer_type,t.product_code 249 | ) 250 | SELECT * 251 | FROM customer_typewise_product_ranking 252 | WHERE sales_ranking <=3; 253 | 254 | -- 17) Top 3 Most frequent customers (with highest no of orders): 255 | 256 | SELECT customer_code, 257 | count(customer_code) as num_of_orders, 258 | RANK() OVER(ORDER BY count(customer_code) DESC) as customer_ranking 259 | FROM transactions 260 | GROUP BY customer_code 261 | LIMIT 3; 262 | 263 | --------------------------------------------------------------------------------