Skip to content

Commit 662c07a

Browse files
committed
Updated distinct count expression to always use COUNTROWS( ALLNOBLANKROW(..) )
1 parent 85c9f80 commit 662c07a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Dax.Model.Extractor/StatExtractor.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ private static string EscapeTableName(Table table)
237237

238238
private static string DistinctCountExpression(Column column)
239239
{
240-
return column.GroupByColumns.Count == 0
241-
? $"DISTINCTCOUNT({EscapeColumnName(column)})"
242-
: $"COUNTROWS(ALLNOBLANKROW({EscapeColumnName(column)}))";
240+
// We always use COUNTROWS(ALLNOBLANKROW(t[c])) instead of DISTINCTCOUNT(t[c]) because it is compatible with GroupByColumns settings, such as Fields Parameters.
241+
// COUNTROWS(ALLNOBLANKROW()) always reads the list of values from the attribute hierarchy (when AvailableInMDX=true) or queries the table if the hierarchy is not available (when AvailableInMDX=false)
242+
243+
return $"COUNTROWS(ALLNOBLANKROW({EscapeColumnName(column)}))";
243244
}
244245

245246
private static string EscapeColumnName(Column column)

0 commit comments

Comments
 (0)