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
Omega
Impactful Individual
Impactful Individual

Creating YTD Table and append in original table

Hi,

 

I have the below table which contains the sales per country, region and month. I am trying to create YTD table that will calculate the total sum for each country and then add the new table to the orignial table. 

 

Is that possible?

 

Old Table:

 

MonthRegionCountrySales
JAN 2017DA10.00
JAN 2017DB20.00
JAN 2017EC30.00
FEB 2017DA30.00
FEB 2017DB50.00
FEB 2017EC90.00

 

 

New Table:

 

MonthRegionCountrySales
JAN 2017DA10.00
JAN 2017DB20.00
JAN 2017EC30.00
FEB 2017DA30.00
FEB 2017DB50.00
FEB 2017EC90.00
YTDDA40.00
YTDDB70.00
YTDEC120.00

 

 

 

 

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @Omega,

Yes, it is possible, please create a new table using the following formula by clicking "New Table" under Modeling on Home page. I assume your old table name is Table1. You can replace it to your table name.

NewTable =
UNION (
    Table1,
    SUMMARIZE (
        ADDCOLUMNS ( Table1, "YTD", "YTD" ),
        [YTD],
        Table1[Region],
        Table1[Country],
        "total", SUM ( Table1[Sales] )
    )
)


You will get expected result as follows.

2.PNG

Best Regards,
Angelia

View solution in original post

4 REPLIES 4
v-huizhn-msft
Employee
Employee

Hi @Omega,

Yes, it is possible, please create a new table using the following formula by clicking "New Table" under Modeling on Home page. I assume your old table name is Table1. You can replace it to your table name.

NewTable =
UNION (
    Table1,
    SUMMARIZE (
        ADDCOLUMNS ( Table1, "YTD", "YTD" ),
        [YTD],
        Table1[Region],
        Table1[Country],
        "total", SUM ( Table1[Sales] )
    )
)


You will get expected result as follows.

2.PNG

Best Regards,
Angelia

Omega
Impactful Individual
Impactful Individual

Thanks a lot @v-huizhn-msft

 

Question: If I have 5 more columns such as factory, city....etc. Do I have to add all 5 columns next to country in the new table formula? 

 

Thanks!

Hi @Omega,

You need to calculate the sum of sales group by region, country, factory, city and so on. We union two new tables in the formula, the number of columns must same if we use UNION function. And please check more details about SUMMARIZE function from here, you will totally understand the formula above.

Best Regards,
Angelia

Omega
Impactful Individual
Impactful Individual

Thanks!

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.