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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Combining data from 2 tables with different date granularity

Hello,
I want to calculate the weekly rotation (=rate of sales) of products sold per store. 

To do that, I have two tables:

- Total sales of specific products at a particular retailer. Each entry has: SAP code, name of retailer, quantity sold, and a date. Granularity here is either monthly (i.e. quantity sold in 1 whole month), or weekly

- Distribution: that is the number of stores (point of sales) in which each product is present. Each entry has: SAP code, name of retailer, number of stores where product is available, and a date.
Granularity here is quarterly.

Weekly rotation should be calculated as: [sum products sold]/[distribution]. So it's the average sales per store.
But I cannot think of way to align the different granularity of date. Can someone help?

Cheers


4 REPLIES 4
Anonymous
Not applicable

Thanks for your suggestions @lucadelicio and @Ashish_Mathur 
The model contains my company's proprietary data, so difficult to share the pbix. But here's where I am at the moment.

There's already a customized date table, including nr of week, month, year, etc.

I have merged the queries "sales" and "distribution" in a new query, with left outer. Because "sales" has the finest date granularity. Matching with "Country", "Date", "SAP" (the product ID), and "Retailer". "CU" is the quatity sold.

Now I need to copy the "Distribution.POS" value to all the rows with "null" in the future until there's a new value, matching with "Country", "SAP", and "Retailer". So I believe it's about creating a new column with a conditional formula. Can you help me with the formula?
Big thanks in advance.

Capture d'écran 2023-07-09 134405.png

In power query transform data add a conditional column.

lucadelicio_0-1688911427854.pnglucadelicio_1-1688911483323.png

If Column equals null then value else Column
This is the M code:
= Table.AddColumn(#"Changed Type", "Custom", each if [Column5] = null then 156 else [Column5])

Hope i help you.

Mark it as a solution if you resolve your problem.

Ciao!



Luca D'Elicio

LinkedIn Profile
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with calculated column formulas for Year, Quarter, Month name and Month number.  Sort the Month name column by the Month number.  To your visual, drag Year and Quarter from the calendar Table.  Write these measures:

Qty sold = sum('Sales'[Quantity sold])

Dist = sum('Distribution'[Quantity])

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lucadelicio
Super User
Super User

It's more easier to help you if you upload your pbix.
Also image of the relationship and the image of the table.
You can try to report the single data in every table with a calculated column.
Then create a data table (with all the day of all the year present in the other table).
Then use it like a slicer to select and filter the divide measure to calculate the result.

I hope I have been helpful.
Mark it as a solution if resolve your problem.

Ciao!



Luca D'Elicio

LinkedIn Profile

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.