Forum Discussion
yuvalpi
4 years agoHelper I
count unique record based on several columns
hi, i have a question regarding unique records. i have the following table: key description release 111 item for sale rel1 111 item for sale rel1 111 item for sale rel2 111 ...
- 4 years ago
yuvalpi OKK 🙂 So I didn't understand what you meant.
This is the column you need:Column 2 = VAR _current_key = 'Table'[key] VAR _result = CALCULATE( DISTINCTCOUNT( 'Table'[release] ), REMOVEFILTERS('Table'), 'Table'[key] = _current_key ) RETURN _result - 4 years ago
yuvalpi you mean like this?:
Column 2 = VAR _current_key = 'Table'[key] VAR _result = CALCULATE( DISTINCTCOUNT( 'Table'[release] ), REMOVEFILTERS('Table'), 'Table'[key] = _current_key, 'Table'[release] <> BLANK() ) RETURN _result
yuvalpi
4 years agoHelper I
Hi again,
I have a followup question.
How can I ingore blanks in the Release column? e.g. for this table to count only the rel1 and rel3, but not the blank value as an item.
| key | description | release | unique |
| 111 | item for sale | rel1 | 2 |
| 111 | item for sale | rel1 | 2 |
| 111 | item for sale | 2 | |
| 111 | item for sale | 2 | |
| 111 | item missing | rel3 | 2 |
thanks again,
SpartaBI
4 years agoCommunity Champion
yuvalpi you mean like this?:
Column 2 =
VAR _current_key = 'Table'[key]
VAR _result =
CALCULATE(
DISTINCTCOUNT( 'Table'[release] ),
REMOVEFILTERS('Table'),
'Table'[key] = _current_key,
'Table'[release] <> BLANK()
)
RETURN
_result
- SpartaBI4 years agoCommunity Champion
yuvalpi my pleasure :))
Really, check out this report:
https://community.powerbi.com/t5/Data-Stories-Gallery/Contoso-by-SpartaBI/m-p/2449543