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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Reduce data rows

I've a table of purchased items stored in the Data Warehouse. The table has almost 20 million records. The table maintains daily transactions and hence the number if rows is huge.

I want to find a way where I can group the entries in the table where I can group items for each month for each customer. 

 

So transfer the example table below:

 

Date (DD/MM/YYYY)Material #QTYgroupCustomer
1/2/2023PN1233StationaryA
1/2/2023BK1233StationaryB
2/2/2023PN1232StationaryA
3/2/2023PN1236StationaryB
1/3/2023LT1234ITA
1/3/2023NB1233ITB
2/3/2023PN1236StationaryA
3/3/2023BK1233StationaryB
4/3/2023MS1232ITB

 

To be similar to this one

 

DateMaterialGoupCustomerQTY
Feb-23PN123StationaryA5
Feb-23BK123StationaryB3
Feb-23PN123StationaryB6

 

I want to do this as I load the data from the Data Warehouse

1 ACCEPTED SOLUTION

Hey @Anonymous !

You can write your SQL like below:

SELECT 

 EXTRACT(YEAR FROM YOUR_DATE_FIELD) AS year,
  EXTRACT(MONTH FROM  YOUR_DATE_FIELD) AS month,
    CUSTOMER, GROUP, MATERIAL,
  SUM(CUSTOMER_QUANTITY) AS CUSTOMER_QUANTITY
FROM YOUR_TABLE
GROUP BY
  EXTRACT(YEAR FROM YOUR_DATE_FIELD),
  EXTRACT(MONTH FROM YOUR_DATE_FIELD),
    CUSTOMER,
   MATERIAL,
   GROUP
 
If this helps, please mark this question as solved to help people find quickly in our community!

Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



View solution in original post

3 REPLIES 3
marcelsmaglhaes
Super User
Super User

Hey @Anonymous !

 

Can you write a SQL to extract the data? If yes, you can try use a group BY, or even create a view to reduce. 

If you can write a SQL, you can use the Group BY function on Power Query (Group By in Power BI using Power Query Editor - SqlSkull).

If this helps, please mark this question as solved to help people find quickly in our community!

 

Regards,
Marcel


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



Anonymous
Not applicable

Thanks. Yes, I can write SQL statement as I import the data from Oracle DB.

I'm not expert with SQL, so I was wondering how would grouping discard the data and just keep the month and year?

 

Hey @Anonymous !

You can write your SQL like below:

SELECT 

 EXTRACT(YEAR FROM YOUR_DATE_FIELD) AS year,
  EXTRACT(MONTH FROM  YOUR_DATE_FIELD) AS month,
    CUSTOMER, GROUP, MATERIAL,
  SUM(CUSTOMER_QUANTITY) AS CUSTOMER_QUANTITY
FROM YOUR_TABLE
GROUP BY
  EXTRACT(YEAR FROM YOUR_DATE_FIELD),
  EXTRACT(MONTH FROM YOUR_DATE_FIELD),
    CUSTOMER,
   MATERIAL,
   GROUP
 
If this helps, please mark this question as solved to help people find quickly in our community!

Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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