Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all,
I need a conversion from SQL to DAX. It seems so simple but I could not figure it out.
What I need is, simply put, the number of email addresses against every line in the given table, here FactSales. I would like to have it as a calculated column rather than a measure.
SELECT EMAIL,COUNT(*) OVER (PARTITION BY EMAIL) NumberOfEmailAddress
FROM FactSales
WHERE EMAIL IS NOT NULL
SalesOrderID | EmailCount | |
1 | a@hotmail.com | 3 |
1 | a@hotmail.com | 3 |
2 | a@hotmail.com | 3 |
3 | b@gmail.com | 2 |
4 | b@gmail.com | 2 |
6 | c@yahoo.com | 4 |
7 | c@yahoo.com | 4 |
7 | c@yahoo.com | 4 |
7 | c@yahoo.com | 4 |
Thanks in advance for any replies
Solved! Go to Solution.
Hi mhakyil, this is classic "simple yet not easy"... because like your SQL PARTITION, the window is needed for context, so add calculated column as:
DAX EmailCount =
CALCULATE(
COUNT('FactSales'[EMAIL]),
ALLEXCEPT('FactSales', 'FactSales'[EMAIL])
)
Hi mhakyil, this is classic "simple yet not easy"... because like your SQL PARTITION, the window is needed for context, so add calculated column as:
DAX EmailCount =
CALCULATE(
COUNT('FactSales'[EMAIL]),
ALLEXCEPT('FactSales', 'FactSales'[EMAIL])
)
I don't read SQL very well, what are you trying to do? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Note, that article specifically calls out, don't just post SQL and ask for a translation to DAX/M...
I thought the code would speak for it self. What I need is, simply put, the number of email addresses against every line in the given table, here FactSales. I would like to have it as a calculated column rather than a measure.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
10 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
13 | |
12 | |
11 | |
8 |