Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views16 pages

Posts

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 16

SQL Windows Functions can be game-changers in your data analysis toolkit.

Here
are some key use cases:

1⃣ Rank: Identify the top entries in a category

2⃣ Lag/Lead: Compare rows in your dataset

3⃣ Aggregate: Perform calculations without losing detail

These functions can help you derive insights more efficiently. Start exploring now! 🌟

SQL Windows Functions can be game-changers in your data analysis toolkit. Here
are some key use cases:

1⃣ Rank: Identify the top entries in a category

2⃣ Lag/Lead: Compare rows in your dataset

3⃣ Aggregate: Perform calculations without losing detail

These functions can help you derive insights more efficiently. Start exploring now! 🌟

Power BI is a powerful tool for data visualization and business intelligence, and DAX
(Data Analysis Expressions) is its formula language that helps you create custom
calculations. Understanding DAX can greatly enhance your ability to perform
complex data analysis in Power BI. Here are some useful DAX tricks that can
optimize your reports and dashboards:

### Basic DAX Functions

1. **SUM and SUMX**:


- **SUM**: Quickly adds up all the values in a column. For example,
`SUM(Sales[Amount])`.

- **SUMX**: Iterates over a table to evaluate an expression and then adds up the
results. Useful for row-wise calculations. For example, `SUMX(Sales, Sales[Quantity]
* Sales[Price])`.

2. **AVERAGE and AVERAGEX**:

- Similar to SUM and SUMX, but for calculating averages. Use `AVERAGE(Column)`
for simple averages and `AVERAGEX(Table, Expression)` for more complex
scenarios.

3. **CALCULATE**:

- Modifies the filter context of an expression. It’s crucial for creating measures that
depend on certain conditions. For instance, `CALCULATE(SUM(Sales[Amount]), Year
= 2023)` filters the sales to show only those from 2023.

4. **FILTER**:

- Returns a table that has been filtered down to include only specific rows. For
example, `FILTER(Sales, Sales[Amount] > 1000)` returns sales where the amount is
greater than 1000.

### Advanced Techniques

1. **Time Intelligence Functions**:

- Functions like `TOTALYTD`, `SAMEPERIODLASTYEAR`, and `DATESBETWEEN` allow


for complex date-based calculations, essential for year-over-year or month-to-month
comparisons.
2. **Use of Variables**:

- Variables can simplify your DAX expressions by storing intermediate calculations.


This improves readability and performance. For instance:

```DAX

VAR TotalSales = SUM(Sales[Amount])

RETURN TotalSales / 2

```

3. **Using ALL and ALLEXCEPT**:

- The `ALL` function removes all filters from a table or column, while `ALLEXCEPT`
removes all filters except those specified. This is useful for calculating things like
percentages of totals.

4. **Dynamic Ranking**:

- To create rankings that respond dynamically to filter changes, use `RANKX`.


Example:

```DAX

Rank = RANKX(ALL(Sales), Sales[Amount], , DESC)

```

5. **Switching Measures with SWITCH**:


- SWITCH is akin to a case statement, allowing you to choose different results based
on conditions. For example:

```DAX

SWITCH(

TRUE(),

Sales[Amount] > 1000, High,

Sales[Amount] > 500, Medium,

Low

```

### Optimizing Performance

1. **Minimize Calculated Columns**:

- Use measures instead of calculated columns where possible. Measures are


calculated on the fly and don’t increase model size.

2. **Limit the Use of LOOKUPVALUE**:

- LOOKUPVALUE is powerful but can slow down performance when overused.


Consider restructuring your data model or using relationships instead.
3. **Avoid Complex Filters in Relationships**:

- Relationships in Power BI should remain simple; use DAX for complex filtering
logic to maintain report performance.

### Visualization Tips

1. **Conditional Formatting**:

- Use DAX measures to create dynamic conditional formatting. This can highlight
important data points based on calculated logic.

2. **Dynamic Titles and Tooltips**:

- Create measures for dynamic titles and tooltips that change based on the context.
Example:

```DAX

PageTitle = Sales Report for & SELECTEDVALUE(Dates[Year])

```

3. **Bookmarks and Selections**:

- Use bookmarks and the selection pane to create interactive reports that respond
to user inputs without needing complex DAX.

By leveraging these DAX tricks, you can enhance your data analysis capabilities in
Power BI, create more insightful reports, and improve the overall performance of
your dashboards. Remember, the key to mastering DAX is practice and
experimentation, so keep exploring and testing different approaches to find what
works best for your specific data scenarios.

Working with dates in databases is a crucial task that often requires specific
functions and techniques to manipulate and analyze temporal data. This guide will
explore date function tricks across the four major database management systems:
MySQL, PostgreSQL, SQL Server, and Oracle.

### MySQL Date Functions

1. **Current Date and Time**

- `CURDATE()`: Returns the current date.

- `NOW()`: Returns the current date and time.

2. **Date Arithmetic**

- `DATE_ADD(date, INTERVAL value unit)`: Adds an interval to a date.

- `DATE_SUB(date, INTERVAL value unit)`: Subtracts an interval from a date.

3. **Date Extraction**

- `YEAR(date)`: Extracts the year from a date.

- `MONTH(date)`: Extracts the month from a date.

- `DAY(date)`: Extracts the day from a date.


4. **Date Formatting**

- `DATE_FORMAT(date, format)`: Formats a date according to the specified format.

### PostgreSQL Date Functions

1. **Current Date and Time**

- `CURRENT_DATE`: Returns the current date.

- `CURRENT_TIMESTAMP`: Returns the current date and time with time zone.

2. **Date Arithmetic**

- `date + interval '1 day'`: Adds an interval to a date.

- `date - interval '1 day'`: Subtracts an interval from a date.

3. **Date Extraction**

- `EXTRACT(YEAR FROM date)`: Extracts the year from a date.

- `EXTRACT(MONTH FROM date)`: Extracts the month from a date.

- `EXTRACT(DAY FROM date)`: Extracts the day from a date.

4. **Date Formatting**

- `TO_CHAR(date, 'YYYY-MM-DD')`: Converts a date to a string with the specified


format.
### SQL Server Date Functions

1. **Current Date and Time**

- `GETDATE()`: Returns the current date and time.

- `SYSDATETIME()`: Returns the current date and time with more precision.

2. **Date Arithmetic**

- `DATEADD(day, value, date)`: Adds a specified number of days to a date.

- `DATEDIFF(day, start_date, end_date)`: Returns the number of days between two


dates.

3. **Date Extraction**

- `YEAR(date)`: Extracts the year from a date.

- `MONTH(date)`: Extracts the month from a date.

- `DAY(date)`: Extracts the day from a date.

4. **Date Formatting**

- `FORMAT(date, 'yyyy-MM-dd')`: Formats a date according to the specified pattern.

### Oracle Date Functions


1. **Current Date and Time**

- `SYSDATE`: Returns the current date and time.

- `SYSTIMESTAMP`: Returns the current date and time with time zone.

2. **Date Arithmetic**

- `date + INTERVAL '1' DAY`: Adds an interval to a date.

- `date - INTERVAL '1' DAY`: Subtracts an interval from a date.

3. **Date Extraction**

- `EXTRACT(YEAR FROM date)`: Extracts the year from a date.

- `EXTRACT(MONTH FROM date)`: Extracts the month from a date.

- `EXTRACT(DAY FROM date)`: Extracts the day from a date.

4. **Date Formatting**

- `TO_CHAR(date, 'YYYY-MM-DD')`: Converts a date to a string in the specified


format.

### Common Tricks and Tips

- **Handling Time Zones:** Consider the time zone settings in your database,
especially if your application serves multiple regions.
- **Leap Years and Daylight Saving Time:** Be aware of special date considerations
like leap years and daylight saving time adjustments.

- **Indexing Date Columns:** Index date columns when performing frequent queries
to improve performance.

- **Date Ranges:** Use BETWEEN to filter data within a specific date range.

- **Avoid String Manipulations:** Whenever possible, use built-in date functions


rather than string manipulations to ensure date accuracy.

By understanding and utilizing these date functions across various database


systems, you can efficiently manage and manipulate date and time data in your
applications.

--

Practicing at least one question a day can help you crack any Data Engineering SQL
interview.

Consistency is the key!!

𝗕𝗲𝘀𝘁 𝗽𝗹𝗮𝘁𝗳𝗼𝗿𝗺𝘀 𝘁𝗼 𝗽𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗦𝗤𝗟 𝗽𝗿𝗼𝗯𝗹𝗲𝗺𝘀 𝗱𝗮𝗶𝗹𝘆

- LeetCode - https://lnkd.in/gkCpv7NA
- HackerRank - https://lnkd.in/gnFS4frz
- SQLZoo - https://sqlzoo.net/
- Mode Analytics - https://lnkd.in/gRPrQrf5
- SQL Bolt - https://sqlbolt.com/
- GeeksforGeeks - https://lnkd.in/ggYbizNB
- LearnSQL - https://www.learnsql.com/
- LearnMode - https://lnkd.in/gQYCkwS2
- Strata Scratch - https://lnkd.in/gYtZQY53
- DataLemur - https://datalemur.com/
- SQL Fiddle - http://sqlfiddle.com/
- DB-Fiddle - https://www.db-fiddle.com/
- SQL Exercises - https://lnkd.in/d89TewuQ
- SQL Practice Set - https://lnkd.in/ddn7hfeu
- DataCamp - https://lnkd.in/dUyvbSwC
- Kaggle - https://lnkd.in/dn83kbwv
- Mode SQL Tutorial - https://lnkd.in/d53iPD-U

====
- SQL Murder Mystery - https://lnkd.in/dtVqDV-g

===

Mastering Power BI: My Journey with Codebasics Bootcamp 🎯

I’m excited to share that I’ve successfully completed the Power BI Data Analytics
Bootcamp 2.0 by Codebasics.

I wanted to take my time to truly digest everything I learned before sharing this
achievement.

Let me be real—diving into data analytics while being a full-time mom has been
one of the hardest things I’ve done.

Trying to understand DAX formulas and build dashboards between meal preps,
bedtime routines, and school runs felt nearly impossible at times. But I kept
pushing, reminding myself why I started this journey.

It wasn’t easy, but every challenge has made me stronger and more determined.

This course was an eye-opener, helping me transform raw data into actionable
insights and empowering me to tackle real-world data challenges confidently.

Here’s a breakdown of what I learned and how it’s shaping my data analytics
journey:
📚 Key Learning Areas Covered:

🔹 Power BI Basics:

An introduction to Power BI, setting the foundation for data exploration and
validation.

🔹 Project Planning & Scoping:

Learning to define project objectives and plan for successful execution.

🔹 Data Collection & Exploration:

Gained expertise in gathering and validating data from various sources to ensure
accuracy.

🔹 Data Transformation in Power Query:

Cleaning and preparing data for analysis—an essential step in the data pipeline.

🔹 Removing DAX Fear:

Mastering DAX (Data Analysis Expressions) to create complex calculations and


enhance data insights.

🔹 Building Finance, Sales, Marketing, & Supply Chain Views:

Developing comprehensive views for key business domains and translating them
into meaningful insights.

🔹 Designing an Effective Dashboard:

Learning how to create user-friendly, actionable dashboards tailored to


stakeholder needs.

🔹 Deploying the Solution in Power BI Service:

Understanding how to deploy dashboards and reports for collaboration and real-
time updates.

🔹 Stakeholder Review & Feedback Implementation:

Practical exposure to receiving feedback and refining the solution to meet


stakeholder expectations.

💡 Other Essential Skills Developed:

Critical Thinking for Data Interpretation

Problem-Solving in Data Scenarios

Project & Stakeholder Management

Effective Reporting and Presenting Insights

I’m incredibly grateful to Dhaval Patel Sir, Hemanand Vadivel Sir, and the entire
Codebasics Bootcamp team for their guidance and expertise.
The real-world projects, exercises, and in-depth explanations have been invaluable
in helping me grow as a data analyst.

I’m excited to share my project presentation soon, along with the key learnings
that came from this journey. Stay tuned! 😉

hashtag#DataAnalytics hashtag#PowerBI hashtag#CodebasicsBootcamp


hashtag#DataTransformation hashtag#Visualization hashtag#DataScience
hashtag#DAX hashtag#BusinessIntelligence hashtag#ContinuousLearning
hashtag#Gratitude
Power of Data!

Learn Power Query with these 8 tutorials 👇

1️⃣ How Power Query Will Change the Way You Use Excel by Leila Gharani

https://lnkd.in/ehYiDnkP

2️⃣ Power Query Beginner to PRO Masterclass in 30 minutes by Purna Duggirala


https://lnkd.in/eGtDGV6K

3️⃣ How to use Microsoft Power Query by Kevin Stratvert

https://lnkd.in/eDrg3Eck

4️⃣ Excel Power Query Tutorial First Steps by Adam Grant

https://lnkd.in/esnHzS35

5️⃣ 10 Power Query tips EVERY user should know by Mark Proctor

https://lnkd.in/ePHDhX2V

6️⃣ 5 Best Practices in Power Query by Chandeep Chhabra

https://lnkd.in/e5c_rbjA

7️⃣ Power Query Tutorial for Beginners by Simon Sez IT

https://lnkd.in/egra3qhS

8️⃣ Get Data From SharePoint or OneDrive with Power Query by Mynda Treacy

https://lnkd.in/edSaWj8m

Shoutout to Purna Duggirala who I wrote "Dashboards for Excel" with, where he
goes in depth about Power Query

I’ve also taken Chandeep Chhabra’s M Course so I could deepen my understanding

The folks in this list are some of the smartest Excel nerds I know 🤓

Don’t put off learning Power Query any longer and get started with these tutorials

Which one are you watching first?

You might also like