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.
I have a table where I have used a DAX formula to determine if a row is a "duplicate" by counting the number of occurrences. In this scenario, a duplicate is when the values of Fruit and Color in one row both match the values for Fruit and Color in another row.
Table1
Fruit | Color | Occurences |
Apple | Red | 1 |
Apple | Green | 3 |
Grape | Purple | 2 |
Apple | Green | 3 |
Grape | Green | 1 |
Apple | Green | 3 |
Grape | Yellow | 1 |
Apple | Yellow | 1 |
Grape | Purple | 2 |
Fruit | Color | Occurrences |
Apple | Green | 3 |
Grape | Purple | 2 |
Thanks in advance.
Solved! Go to Solution.
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
It is for creating a new table.
Expected table =
SUMMARIZE(
FILTER(
ADDCOLUMNS(
Table1,
"@occurences", VAR _CurrentFruit = 'Table1'[Fruit]
VAR _CurrentColor = 'Table1'[Color]
RETURN
COUNTROWS(FILTER(
'Table1',
'Table1'[Fruit] = _CurrentFruit &&
'Table1'[Color] = _CurrentColor
)
)
),
[@occurences] > 1
),
Table1[Fruit],
Table1[Color],
[@occurences]
)
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
It is for creating a new table.
Expected table =
SUMMARIZE(
FILTER(
ADDCOLUMNS(
Table1,
"@occurences", VAR _CurrentFruit = 'Table1'[Fruit]
VAR _CurrentColor = 'Table1'[Color]
RETURN
COUNTROWS(FILTER(
'Table1',
'Table1'[Fruit] = _CurrentFruit &&
'Table1'[Color] = _CurrentColor
)
)
),
[@occurences] > 1
),
Table1[Fruit],
Table1[Color],
[@occurences]
)
Thank you @Jihwan_Kim ! It seems to provide the correct answer for me, but I want to be sure I applied it as you intended. I created a new measure and used this to get "2" as my value. As it's my first time using "Summarize", it's new to me. It's interesting to see that I can generate a virtual table, I didn't know about this functionality.
# Distinct Duplicates =
VAR _Table = SUMMARIZE(
FILTER(
ADDCOLUMNS(
Table1,
"@occurences", VAR _CurrentFruit = 'Table1'[Fruit]
VAR _CurrentColor = 'Table1'[Color]
RETURN
COUNTROWS(FILTER(
'Table1',
'Table1'[Fruit] = _CurrentFruit &&
'Table1'[Color] = _CurrentColor
)
)
),
[@occurences] > 1
),
Table1[Fruit],
Table1[Color],
[@occurences]
)
RETURN COUNTROWS(_Table)
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
11 | |
9 | |
6 |