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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Month comparison (day over day)

Hello,

 

I'm trying to generate a similar report as below where I want to compare daily orders (day over day) and how many of these orders were delivered (Cumulative).

Each month should be 60 days.

yousefaljohani_0-1594027722075.png

Sample Data:

order #Order datestatusdelivery date
12306/15/2020Completed07/01/2020
32106/15/2020Completed07/13/2020
43106/15/2020In Progress 
31206/20/2020Completed07/13/2020
64506/20/2020Completed06/25/2020
75306/20/2020Completed06/30/2020
42306/20/2020Completed07/13/2020
23406/20/2020Completed07/13/2020
67806/20/2020Completed07/13/2020
98706/20/2020Completed07/13/2020
87006/20/2020In Progress 
98606/20/2020Completed07/13/2020
67806/20/2020Completed07/13/2020

 

what is the best way to accomplish this?

 

Thanks,

Y

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , Create a date table, join both date with that table. One will active join another will be inactive. Use userelation to activate the join

 

Cumm Order = CALCULATE(Count(Table[order #]),filter(date,date[date] <=maxx(date,date[date])), userelation(Date[Date],Table[Order date]))
or

Cumm Order = CALCULATE(Count(Table[order #]),filter(date,date[date] <=max(Table[Order date])), userelation(Date[Date],Table[Order date]))

 

Cumm delivery= CALCULATE(Count(Table[order #]),filter(date,date[date] <=maxx(date,date[date])), userelation(Date[Date],Table[delivery  date]))
or
Cumm delivery= CALCULATE(Count(Table[order #]),filter(date,date[date] <=max(Table[delivery  date])), userelation(Date[Date],Table[delivery  date]))

 

Userelation is only needed for an inactive one. I have shown in both.

 

refer example

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

 

// Orders - fact table with orders, each line
// is one unique order.
// Calendar - date table connected to Orders
// in two ways:
// 1. Active connection
//		[Date] 1 -- * [OrderDate]
// 2. Inactive connection
//		[Date] 1 -- * [DeliveryDate]
// Columns in a fact table must always be
// hidden and slicing takes place via dimensions
// only. Calendar must be a Date table marked
// as such in the model.

[Orders Made] = COUNTROWS( Orders )

[Orders Delivered] =
	CALCULATE(
		[Orders Made],
		USERELATIONSHIP(
			Orders[DeliveryDate],
			Calendar[Date]
		)
	)
	
// Cumulative number of orders made
// to date.
[Orders Made Cumul.] =
var __lastVisibleDate = MAX( Calendar[Date] )
var __result =
	CALCULATE(
		[Orders Made],
		Calendar[Date] <= __lastVisibleDate
	)
return
	__result
	

// Cumulative number of orders delivered
// to date.
[Orders Delivered Cumul.] =
var __lastVisibleDate = MAX( Calendar[Date] )
var __result =
	CALCULATE(
		[Orders Delivered],
		Calendar[Date] <= __lastVisibleDate,
		KEEPFILTERS( Orders[Status] = "completed" )
	)
return
	__result

 

 

Note that in a correctly built model the fact table should all be hidden and slicing should only be done through dimensions. I've assumed, though, that Status will be still kept in the fact table and you'll want to slice by it, hence KEEPFILTERS( Orders[Status] = "completed" ). However, Status should also be kept in a dimension and, with some very specific exceptions, the fact table should be HIDDEN (can't stress this enough).

 

Best

D

Anonymous
Not applicable

Thank you @Anonymous and @amitchandak 

 

Now, what I have looks like this:

yousefaljohani_0-1594102424434.png

 

and below is what I'd like to acheive, I want to represent each month to start from day 1 and keep going till 60.

 

yousefaljohani_1-1594102846797.png

Pease let me know if you need more calrification.

 

Thanks,

Y

 

Anonymous
Not applicable

Dears,

For more clarification. I'm doing this on excel, and I couldn't fiqure it out how to do it in Power BI.

Below is how I do it in excel, and this is excatly how i need it to be in Power BI.

yousefaljohani_0-1594733537824.png

 

Your support is much appreciated.

 

Regards,

Y

Anonymous
Not applicable

To do what you want, you have to create another table that will store numbers from 1 to 60 and will map each of the numbers to the relevant days for each of the months you have. It'll just be like:

Calendar[Date] 1<--* BridgeTable[Date]

You have to do this because, for instance, each date will be mapped to at least 2 different months (maybe even more). The table with numbers will have to have some more attributes that will let you slice by months. This is because a month will be mapped into 60 days, so you can't do it with the Date table only.

Best
D

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.