Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hello:
I am looking to see how you would answer these two questions using SQL? Any input is appreciated! Thanks
| Customer Name | Month & Year | Sales Amt |
| A | Jan-20 | 100 |
| B | Feb-20 | 200 |
| C | Mar-20 | 300 |
| D | Apr-20 | 400 |
| C | Oct-21 | 600 |
| F | Nov-21 | 700 |
| G | Dec-21 | 800 |
| SQL Code for New Customers in 2021? |
| Name | Dept | ID | Change Null to: | |
| a | null | 1 | hr | |
| b | finance | 2 | ||
| c | null | 3 | finance | |
| d | logistics | 4 |
Solved! Go to Solution.
Hi @Whitewater100,
As lbendlin said, your requirement seems more related to t-SQL query coding. You can post at the SQL Server forum to get better support.
In addition, you can also try to use the following follow if it helps.
Steps:
1. Create a select query to search customer names from the raw table.
2. Add a subquery to search the customer names from the table when the year of date is less than 2021.
Subqueries (SQL Server) - SQL Server | Microsoft Docs
3. Use t-SQL 'Not IN' operator to add conditions to the main query to get customers that are not included in the subquery.
SQL NOT IN Operator (mssqltips.com)
For example:
select
*
from
Sales as s
where
s.CustomerName not in (
select
CustomerName
from
Sales
where
Year(Sales.Date) < 2021
)
Regards,
Xiaoxin Sheng
Hi @Whitewater100,
As lbendlin said, your requirement seems more related to t-SQL query coding. You can post at the SQL Server forum to get better support.
In addition, you can also try to use the following follow if it helps.
Steps:
1. Create a select query to search customer names from the raw table.
2. Add a subquery to search the customer names from the table when the year of date is less than 2021.
Subqueries (SQL Server) - SQL Server | Microsoft Docs
3. Use t-SQL 'Not IN' operator to add conditions to the main query to get customers that are not included in the subquery.
SQL NOT IN Operator (mssqltips.com)
For example:
select
*
from
Sales as s
where
s.CustomerName not in (
select
CustomerName
from
Sales
where
Year(Sales.Date) < 2021
)
Regards,
Xiaoxin Sheng
Thank you Xiaxin and Ibendlin for replyimg to my question. Very much appreciated!
you posted this in the Power BI forums?
Hi:
Do you know where I should ask this? I asked on Developer forum, on this web site. Thank you
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |