Forum Discussion

djbc1986's avatar
djbc1986
Frequent Visitor
6 years ago

Groupby function with round calculation error

Hi there.

 

During the last week, I've been learning about DAX working with the WideWorldImportersDW database, and I've got this question, using summarizecolummns I can get a rounded number when calculating my expression.

 

 

EVALUATE
	SUMMARIZECOLUMNS	(
				'Dimension City'[State Province],
				'Dimension City'[City],
				'Dimension Date'[Fiscal Year],
				FILTER('Fact Sale',  RELATED('Dimension City'[State Province])="Washington" && RELATED('Dimension City'[City])="Midland"),
				"Total Sales SC", ROUND(SUMX('Fact Sale', 'Fact Sale'[Quantity]*'Fact Sale'[Unit Price]),0)
				)
				

 

                

However, if I try to do the same with the Groupby function, I'm getting this error:

 

 

EVALUATE
	GROUPBY		(
				FILTER('Fact Sale', AND(RELATED('Dimension City'[State Province])= "Washington",RELATED('Dimension City'[City])="Midland")),
				'Dimension City'[State Province],
				'Dimension City'[City],
				'Dimension Date'[Fiscal Year],
				"Total Sales GB", ROUND(SUMX(CURRENTGROUP(), 'Fact Sale'[Quantity]*'Fact Sale'[Unit Price]),0)
				)	

 

 

 

 

 

Function 'GROUPBY' scalar expressions have to be Aggregation functions over CurrentGroup(). The expression of each Aggregation has to be either a constant or directly reference the columns in CurrentGroup().

 

Is there a way to solve this in the same piece of code? Or is it necessary to use calculate?

1 Reply