Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

New Distinct Column that only counts the Value once and it only show it on the 1st duplicate

Hi,

I am trying to create a Column that only show the value if is duplicate on the first line. rather than repeating the distinc count on every single row..  I added the earlier on ID and also on RowNumber but get same results.

Show Only Once = CALCULATE(DISTINCTCOUNT('Table1[ID]),'Table1'[SiteID]=EARLIER('table1'[ID]))
 
Any help will be greatly appreciated Thanks,
 
RowNumberIDDistinctCountShow only Once
1534322
353432 
4433322
543332 
6133311

 

1 ACCEPTED SOLUTION
edhans
Super User
Super User

There might be a faster way to do this, but this builds each step one at a time @Anonymous 

edhans_0-1613605351268.png

First Distinct = 
VAR varCurrentID = [ID]
VAR varCurrentRow = 'DataTable'[RowNumber]
VAR varFirstRow = 
    MINX(
        FILTER(
            'DataTable',
            'DataTable'[ID] = varCurrentID
        ),
        'DataTable'[RowNumber]
    )
VAR varCounts = 
    COUNTX(
        FILTER(
            'DataTable',
            'DataTable'[ID] = varCurrentID
        ),
    'DataTable'[ID]
    )
RETURN
    IF(
        varCurrentRow = varFirstRow,
        varCounts,
        BLANK()
    )

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thank You for quick response...Edhans😀

Glad to help @Anonymous 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

There might be a faster way to do this, but this builds each step one at a time @Anonymous 

edhans_0-1613605351268.png

First Distinct = 
VAR varCurrentID = [ID]
VAR varCurrentRow = 'DataTable'[RowNumber]
VAR varFirstRow = 
    MINX(
        FILTER(
            'DataTable',
            'DataTable'[ID] = varCurrentID
        ),
        'DataTable'[RowNumber]
    )
VAR varCounts = 
    COUNTX(
        FILTER(
            'DataTable',
            'DataTable'[ID] = varCurrentID
        ),
    'DataTable'[ID]
    )
RETURN
    IF(
        varCurrentRow = varFirstRow,
        varCounts,
        BLANK()
    )

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors