Forum Discussion

pbiwizard's avatar
pbiwizard
Frequent Visitor
3 years ago
Solved

Group by, Removing Duplicates, and Adding Rows

Hi! 

I am looking for help with removing duplicates when grouping, and adding a column. Or however, I can achieve the second table (i just started off with group-by and summing but that did not work because to double counts my rows). 

Here is an example: 

Key IDGross SalesExempt SalesNonTaxed SalesAmount Subject to TaxSales TaxRate

00001

100.00

00100.006.006%
00001100.0000100.001.001%
00001100.0000100.000.500.5%
00001100.0000100.002.002%
0000250.00050.00000
0000220.000020.0010.0050%
0000375.0075.0000

0

0
0000430.000

30.00

000
0000410.000010.001.0010%
0000430.00030.00000
0000410.000010.002.0020%

Above we have instances where I there are duplicates in several columns. However, the driving factors are the Gross Sales and the Rate, along with the transaction ID. However, since there are different sales taxes depending on jurisdiction, the rows repeat for the transaction (even though they are blank since the exempt and non-taxable amount drive the rate (if there is something in this column then the rate is 0). 

 

This is what I would like the column to look like. 

Key IDGross SalesExempt SalesNonTaxed SalesAmount Subject to TaxSales TaxRate

00001

100.00

00100.009.507.5%
0000270.00050.0020.0010.0050%
0000375.0075.0000

0

0
0000440.000

30.00

10.003.0030%

I would like one row per key. If the values in each colum (per key) I would like them to be added, other wise they will be double counted and that is incorrect. So if the values are different, I would like them to be added. 

 

Thank you! 

  • pbiwizard You don't need to create a new table, just add measure for each column and then use that in the visual, here is the example of the measure for Gross Sales

     

    Gross Sales M = 
    SUMX ( 
        SUMMARIZE ( TableSum, TableSum[Key ID], TableSum[Gross Sales] ), 
        [Gross Sales] 
    )

1 Reply

  • pbiwizard You don't need to create a new table, just add measure for each column and then use that in the visual, here is the example of the measure for Gross Sales

     

    Gross Sales M = 
    SUMX ( 
        SUMMARIZE ( TableSum, TableSum[Key ID], TableSum[Gross Sales] ), 
        [Gross Sales] 
    )