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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.