Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
11 | |
9 | |
6 |