Forum Discussion

antlufc's avatar
antlufc
Frequent Visitor
6 years ago

Duplicate Values Making Sub and Grand Totals Incorrect

Hi All

 

I need to calculate a sales value based upon id and stage being closed won. 

 

In my data the "ID" has duplicates, so what i want to do is get the total value of sales without it duplicating. I need to use a dax measure to achieve this.  For example an ID appears twice and it is doubling the sales value.  So with example below in my matrix it showing ID as 200 for the sales value, it should be 100 as this id has been duplicated. 

 

ID       Sales Value

1          100

1           100

2             50

3             50

 

i have used the below to get the show what IDs have been duplicated:

Measure 1 =
 
COUNTROWS(FILTER(VALUES(Table1[Id]),CALCULATE(COUNT(Table1[Id]) > DISTINCTCOUNT(Table1[Id]]))))
 
I have then used the below if statement to get my sales value:
 
IF([Measure 1]=1,SUMX(table1,[Salesvalue])/2,SUMx(Table1,[SalesValue]))
 
This has worked on a row level but not on a subtotal or grand total level.
 
Any idea how i can get the correct values to show in the sub and grand totals?