- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

SQL to DAX
I have sql code I want to convert to dax, however, I'm getting different count result
The sql code when run will give 4936
Select count(distinct ItemNo) cnt from Item
Where Status = 'A'
AND (Depot = 'Vendor Delivers' OR Stock ='Direct')
The DAX, I wrote return 4922
Measure =
CALCULATE( DISTINCTCOUNT(Item[ItemNo])
,FILTER(Item,Item[Depot] ="Vendor Delivers"
|| Item[Stock] = "Direct" )
,FILTER(Item,Item[Status] = "A")
)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Here is a different way to write that. You should avoid filtering the whole table in your CALCULATE. Not sure this will give a different answer. However, you can troubleshoot your measure in the Data view on your table. Filter on the two columns for the desired values, and then select the ItemNo column to see the distinctcount below.
NewMeasure =
CALCULATE(
DISTINCTCOUNT( Item[ItemNo] ),
Item[Depot] IN { "Vendor Delivers", "Direct" },
Item[Status] = "A"
)
Pat
Did I answer your question? Mark my post as a solution! Kudos are also appreciated!
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@mahoneypa HoosierBI on YouTube
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Here is a different way to write that. You should avoid filtering the whole table in your CALCULATE. Not sure this will give a different answer. However, you can troubleshoot your measure in the Data view on your table. Filter on the two columns for the desired values, and then select the ItemNo column to see the distinctcount below.
NewMeasure =
CALCULATE(
DISTINCTCOUNT( Item[ItemNo] ),
Item[Depot] IN { "Vendor Delivers", "Direct" },
Item[Status] = "A"
)
Pat
Did I answer your question? Mark my post as a solution! Kudos are also appreciated!
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@mahoneypa HoosierBI on YouTube
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@mahoneypat It didn't work, the Filter are from the same table but different columns Stock column and Depot column
Please check your dax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@Anonymous Try this also,
Measure =CALCULATE( DISTINCTCOUNT(Item[ItemNo]), Item[Depot] ="Vendor Delivers" || Item[Stock] = "Direct" || Item[Status] = "A")
Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
07-08-2024 01:45 PM | |||
04-03-2024 07:17 AM | |||
07-05-2024 06:49 PM | |||
02-15-2024 03:14 AM | |||
Anonymous
| 02-27-2024 11:16 PM |
User | Count |
---|---|
83 | |
78 | |
52 | |
37 | |
36 |
User | Count |
---|---|
104 | |
85 | |
47 | |
44 | |
42 |