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
Anonymous
Not applicable

Adding Rows When there isn't a Ship Date

Hello, I have am editing an excel sheet in Power Query that has columns called ship date, item sold, and quantity. I'm trying to find the average of sales for the month but not every day has a shipment. How should I insert a row containing a 0 and the date with no shipments? Thanks.

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Don't try to force rows into your fact table.

Create a proper calendar table that you can relate to your fact table then use the calendar[date] column to get the number of days in the period as your denominator.

 

Example:

You want to look at all shipments in March 2022.

Your calendar table has [date] and [monthYear] columns.

Your fact table has [shipDate] and [shipValue] (sales) columns.

Relate calendar[date] to fact[shipDate], ONE to MANY.

Create the following measures:

_sales = SUM(fact[shipValue])

_days = COUNTROWS(calendar)

_averageSalesPerDay = DIVIDE(_sales, _days, 0)

 

Put [_averageSalesPerDay] and calendar[monthYear] into a visual and this will calculate the average sales for every day in that month.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you!

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Don't try to force rows into your fact table.

Create a proper calendar table that you can relate to your fact table then use the calendar[date] column to get the number of days in the period as your denominator.

 

Example:

You want to look at all shipments in March 2022.

Your calendar table has [date] and [monthYear] columns.

Your fact table has [shipDate] and [shipValue] (sales) columns.

Relate calendar[date] to fact[shipDate], ONE to MANY.

Create the following measures:

_sales = SUM(fact[shipValue])

_days = COUNTROWS(calendar)

_averageSalesPerDay = DIVIDE(_sales, _days, 0)

 

Put [_averageSalesPerDay] and calendar[monthYear] into a visual and this will calculate the average sales for every day in that month.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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.

Top Solution Authors
Top Kudoed Authors