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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors