I am running into the classic "total row does not agree with sum of detail rows" problem.
I have a type 2 employee schedule dimension table with grain:
employee version + week
I have a measure defined as:
Total Sales =
,'Dimension Employee Schedule'[Category] = "A"
I have a matrix visual with row fields:
[Group] \ [Type]
To correct the Total row in this matrix, I have implemented the following measure:
Total Sales by group and type =VAR __table =SUMMARIZE(
'Dimension Employee Schedule'
,'Dimension Employeee Schedule'[Group]
,'Dimension Employee Schedule'[Type]
HASONEVALUE('Dimension Employee Schedule'[Group])
As far as I know, this is the correct pattern to follow for Total rows. However, my Total row value isn't the sum of the detail rows. How do I correct this measure?
Go to Solution.
Here are the steps you can follow：
1. According to your description, the total may fail due to whether Type is multiple values.
Returns TRUE when the context for columnName has been filtered down to one distinct value only,Otherwise is FALSE.
As shown below:
When a value is selected, it is displayed as True.
When one or more values are selected, it is displayed as False.
2. For the problem of making the head office and the details the same, we can not only use HASONEVALUE, but also use HASONEFILTER function.
The difference between the two functions can be viewed at this link
3. In this regard, I created data to simulate the use of two functions HASONEVALUE and HASONEFILTER for you.
IF(SUM('Dimension Employee Schedule'[Amount])<300,0,SUM('Dimension Employee Schedule'[Amount]))
IF(HASONEFILTER('Dimension Employee Schedule'[Date]),
IF(SUM('Dimension Employee Schedule'[Amount])<300,0,SUM('Dimension Employee Schedule'[Amount])),
SUMX(FILTER('Dimension Employee Schedule',[Amount]>300),[Amount])
var _new=SUMMARIZE('Dimension Employee Schedule','Dimension Employee Schedule'[Date],"_value",[Measure])
return IF(HASONEVALUE('Dimension Employee Schedule'[Date]),[Measure],SUMX(_new,[_value]))
You can downloaded PBIX file from here.
If this response does not meet your needs, can you provide a copy of sample data.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
View solution in original post
Maybe check if Type has one value too?
Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos.
I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query.
Check out the on demand sessions that are available now!
Check out the Winners!
Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.