How do I avoid duplicate values for a column ...

How do I avoid duplicate values for a column in a specific data slice?

Iโ€™m sure this should be simple but I cannot find how to do it! I have a table โ€œTenancy Applicationโ€ with multiple columns but the significant columns for this query are [TenancyAppID], [Tenant] and [TenancyYear].

I want a data slice that includes all columns but only displays a single occurrence of [Tenant] values. Reason being a [Tenant] could occur on one or more row due to having different [TenancyYear] value.

What do I need to add to following filter expression to achieve this?

ISNOTBLANK([Tenant])

(It would also be a bonus if I could sort the records alphabetically at the same time, although I appreciate that I can do this with my selected views)

0 12 2,808
12 REPLIES 12

Soโ€ฆ are you saying that you want to filter duplicate records away with the slice. You only want to show one record from that โ€œgroupโ€?

@Aleksi_Alkio Yes, basically using it to display list of tenantsโ€™ information and do not want the same tenant to appear twice.

Youโ€™re welcome

You would need to add a virtual columnโ€ฆ for example with the MAXROW expression and then filter the data with a formula like [KeyColumn]=[MaxRowColumn]

Thanks Aleksi, Iโ€™ll give it a try

Another way could be a simple formula in initial value when you add a new record. It could be like IFS(NOT(IN([Tenant],TableName[Tenant])),1) and then you can filter it with the simple condition like [TestColumn]=1. This will work if you never delete any record from that table. The good thing is that you donโ€™t need to calculate the MAXROW value every time when you sync the app.

Iโ€™ve tried to create virtual column using

MAXROW(โ€œTenancy Applicationโ€,[TenancyAppID])

but expression builder states

โ€œFunction โ€˜MAXROWโ€™ should have at least two parameters: a table name, a column name, and an optional filter expressionโ€

Try with MAXROW(Tenancy Application,TenancyAppID).

Appears that I am unable to use MAXROW as this returns

โ€œThe inputs for function โ€˜MAXโ€™ should be a list of numeric valuesโ€

My key column [TenancyAppID] is a UNIQUEID() value. Sadly cannot implement your other suggestion as working with live data that has already been entered.

Guess I may have to give up on this idea as already spent loads of time trying to figure out how to do it.

Try with MAXROW(Tenancy Application,_rownumber,[TenancyAppID]=[_THISROW].[TenancyAppID])

That one didnโ€™t work, but managed to get it to work by using the following expressions

For virtual column MAXROW(Tenancy Application, _rownumber, [Tenant]=[_THISROW].[Tenant])

For slice filter

[TenancyAppID]=[_DuplicatesFilter]

Thanks for sticking with me on this, definitely wouldnโ€™t have got there without your help. Once again, great support!

if for a duplicate number format can you use this formula

Top Labels in this Space