Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
guilledo24
Regular Visitor

New column with total by id

Hi,

I have the next table

 

ID  |  SALES

1   |    123

2   |    50

1   |    08

3   |    26

3   |    74

2   |    12

1   |    59

 

And i need to create a new column to have the total sales by id, repeat the total in every id:

 

id  |  SALES  |  TOTAL

1   |    120    |    810

2   |    500    |    620

1   |    100    |    810

3   |    260    |    1000

3   |    740    |    1000

2   |    120    |    620

1   |    590    |    810

3   |    590    |    1000

 

Thanks,

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @guilledo24

 

I think this calculated column gets pretty close

 

Total = 
    CALCULATE(
        SUM('Table1'[Sales]), 
        FILTER(
            'Table1',
            'Table1'[ID]= EARLIER(Table1[ID])
            )
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
guilledo24
Regular Visitor

Can you explain me all the formula?

v-juanli-msft
Community Support
Community Support

Hi @guilledo24

 

Phil_Seamark
Employee
Employee

Hi @guilledo24

 

I think this calculated column gets pretty close

 

Total = 
    CALCULATE(
        SUM('Table1'[Sales]), 
        FILTER(
            'Table1',
            'Table1'[ID]= EARLIER(Table1[ID])
            )
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

@Phil_Seamark thanks for answering, that solution it's excelent.

 

Now I need the same result but the total sales by id, month and year, can you give me the best solution?

 

id  |  SALES  |  MONTH  |  YEAR

1   |    120    |    2           |   2018

2   |    500    |    6           |   2017

1   |    100    |    3           |   2018

3   |    260    |    3           |   2017

3   |    740    |    2           |   2018

2   |    120    |    2           |   2017

1   |    590    |    6           |   2017

3   |    590    |    2           |   2018

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.