Forum Discussion
DISTINCT count for first value DAX
- 6 years ago
Hi Anonymous ,
At first, you need to add an index column in the query editor.
Then you could create a new column to get the result.
Column = VAR a = CALCULATE ( FIRSTNONBLANK ( 'Table'[ID], 1 ), FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 ) ) RETURN IF ( a = 'Table'[ID], 0, 1 )
Hi Anonymous ,
At first, you need to add an index column in the query editor.
Then you could create a new column to get the result.
Column =
VAR a =
CALCULATE (
FIRSTNONBLANK ( 'Table'[ID], 1 ),
FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
)
RETURN
IF ( a = 'Table'[ID], 0, 1 )
- MylèneB5 years agoHelper II
Hello!
How would do it so the number adds up automatically instead of counting 1 each time? So to have kind of an index without the duplicates Id in it?
- Ashish_Mathur5 years agoSuper User
Hi,
Share some data and show the expected result clearly.
- MylèneB5 years agoHelper II
Hi, sorry for my unclear question yesterday.
I have a table with a few names and ids. I want to add a number to similar names if their id are different, so we can see quickly that it's 2 different persons.
ID NAME RESULT
654 John Smith John Smith
123 John Smith John Smith2
123 John Smith John Smith2
789 Jane Doe Jane Doe
I thought of using this solution to count distinct value and then concatene with the names but it's not working since only the first name have a different value. Is it clearer? Thanks a lot for your help!