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.
Can this code be improved to count unique rows based on column A in MY_DATA table?
DEFINE
VAR B =
COUNTROWS (FILTER
(
'MY_DATA',
'MY_DATA'[start time] IN DATESBETWEEN(
'My_DATA'[start time],
DATE(2024, 7, 1), DATE(2024, 7, 31)
)
)
)
EVALUATE
{{B}}
Solved! Go to Solution.
@stribor45 So like this?
DEFINE
VAR B =
COUNTROWS( DISTINCT( SELECTCOLUMNS(FILTER
(
'MY_DATA',
'MY_DATA'[start time] IN DATESBETWEEN(
'My_DATA'[start time],
DATE(2024, 7, 1), DATE(2024, 7, 31)
)
), "__Column", [A] ) )
)
EVALUATE
{{B}}
@stribor45 So like this?
DEFINE
VAR B =
COUNTROWS( DISTINCT( SELECTCOLUMNS(FILTER
(
'MY_DATA',
'MY_DATA'[start time] IN DATESBETWEEN(
'My_DATA'[start time],
DATE(2024, 7, 1), DATE(2024, 7, 31)
)
), "__Column", [A] ) )
)
EVALUATE
{{B}}
I need to adjust the code but I am confused as a distinct function only takes one column table as an argument. This is the code
EVALUATE
SELECTCOLUMNS (
FILTER (
'MY_DATA',
'MY_DATA'[start time]
IN DATESBETWEEN (
'MY_DATA'[start time],
DATE ( 2024, 5, 1 ),
DATE ( 2024, 5, 31 )
)
),
"__Columns", [call duration],
"__Column", [id]
)
Code above produces this table as a result (see the image below). Is there a way to remove duplicates row based on the [id]? Resulting table in the image produces duplicates and I need to end up with only two rows.
@stribor45 DISTINCT has a table version as well: DISTINCT (table) function (DAX) - DAX | Microsoft Learn
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 |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
15 | |
13 | |
11 | |
9 | |
8 |