Forum Discussion
Does filter (All('TableName')) remove duplicates?
- 1 year ago
Hi arunbyc
To answer your question, yes, the value of 1 represents the single "Red" value in the list of unique colors.
When ALL is used with one or more column arguments, it returns all unique values (or combinations of values) from the column(s). The column arguments must all come from the same table. This is just how the function is defined when passed column arguments.
However, when ALL is used with a table argument (which must be a physical table), it retains all rows regardless of duplicates.
In all cases it adds a potential blank row generated for invalid relationships.
So the table expression ALL ( Table[Column] ) will not itself preserve the row count of the underlying table.
I would generally favour using ALL (or REMOVEFILTERS) as a modifier rather than a table expression.
I would personally write the RedProductscount measure something like this (assuming it should return the count of Red products ignoring all filters on the expanded 'Product' table):
RedProductscount = CALCULATE ( COUNTROWS ( 'Product' ), ALL ( 'Product' ), -- or REMOVEFILTERS ( 'Product' ) 'Product'[Color] = "Red" )You could also consider ALLCROSSFILTERED ( 'Product' ) to remove filters outside the expanded 'Product' table that filter 'Product', or simply ALL ( ) to remove all filters.
See here for more detail and examples.
This is also a good article:
Please post back if needed ๐
Hi arunbyc
To answer your question, yes, the value of 1 represents the single "Red" value in the list of unique colors.
When ALL is used with one or more column arguments, it returns all unique values (or combinations of values) from the column(s). The column arguments must all come from the same table. This is just how the function is defined when passed column arguments.
However, when ALL is used with a table argument (which must be a physical table), it retains all rows regardless of duplicates.
In all cases it adds a potential blank row generated for invalid relationships.
So the table expression ALL ( Table[Column] ) will not itself preserve the row count of the underlying table.
I would generally favour using ALL (or REMOVEFILTERS) as a modifier rather than a table expression.
I would personally write the RedProductscount measure something like this (assuming it should return the count of Red products ignoring all filters on the expanded 'Product' table):
RedProductscount =
CALCULATE (
COUNTROWS ( 'Product' ),
ALL ( 'Product' ), -- or REMOVEFILTERS ( 'Product' )
'Product'[Color] = "Red"
)
You could also consider ALLCROSSFILTERED ( 'Product' ) to remove filters outside the expanded 'Product' table that filter 'Product', or simply ALL ( ) to remove all filters.
See here for more detail and examples.
This is also a good article:
Please post back if needed ๐