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
MMJ369
Frequent Visitor

Running total within time periods

Hi,

 

I have to create a graph that shows the value of orders placed every day within a timewindow which need to be shipped within that same time window (between the cutoff dates of two consecutive months). We need to see the ordervalue growing during this timeperiode.

 

I have it working if the time window is a month. But the cut off dates for ordering and shipping are within the month, mostly between the 15th and 20st of the month.

 

So the graph for when the period would be a calendarmonth is this.graph1.PNG

Each period/month is a line and the X-axis is the day of the month.

The lines show the cumulative value of placed orders that can be shipped before the end of that month.

 

I now need to have the cumulative value of orders placed within the preiod and which can be shipped in that period.

OB[OrderDate]>OB[PreviousCutOffDate] && OB[OrderDate]<=OB[CutOffDate]

&& OB[ShipDate]<=OB[CutOffDate]

 

The cutoffdates are lookedup in a different table and stored as a calculated column against each line in OB table.

 

For the end of month calculation I use two measures:

PlacedOrdersThisMonth =
CALCULATE (
 SUM ( OB[OrderValue] ),
 USERELATIONSHIP ( OB[OrderDate], 'Calendar'[Date]),
     FILTER(OB, OB[ShipDate] <= EOMONTH(OB[OrderDate],0)
))

 

AND

 

MTDPlacedOrdersThisMonth =
CALCULATE (
    OB[PlacedOrdersThisMonth],
    FILTER (
        ALLSELECTED ( 'Calendar'[Date] ),
        ISONORAFTER ( 'Calendar'[Date], MAX ( 'Calendar'[Date] ), DESC )))

 

 

How can I get a similar graph for within the cutoffdate periods?

 

PBIX: test COTD.pbix

1 ACCEPTED SOLUTION

Hi @MMJ369,

 

Is it this one? Please check out the demo in the attachment.

PlacedOrdersThisMonth 3 =
CALCULATE (
    IF (
        MIN ( 'Calendar'[Date] ) = MIN ( OB[CutOffDate] ),
        0,
        SUM ( OB[OrderValue] )
    ),
    USERELATIONSHIP ( OB[OrderDate], 'Calendar'[Date] ),
    FILTER ( OB, OB[ShipDate] <= OB[CutOffDate] )
)

Running_total_within_time_periods

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
MMJ369
Frequent Visitor

 

I now have the calculation and graph to show only orders which can be shipped before cutoff date of that order by amending the measure:

PlacedOrdersThisMonth =
CALCULATE (
 SUM ( OB[OrderValue] ),
 USERELATIONSHIP ( OB[OrderDate], 'Calendar'[Date]),
     FILTER(OB, OB[ShipDate] <= OB[CutOffDate]  )
)

 

This gives the graph:

graph2.PNG

where the red orders are not shown as these are shipped after cutoff.

 

The issue which I have left then is that the cumulative value is calculated for all orders, where I would like to start from zero value after each cutoff date. How could I achieve that?

 

Hi @MMJ369,

 

Is it this one? Please check out the demo in the attachment.

PlacedOrdersThisMonth 3 =
CALCULATE (
    IF (
        MIN ( 'Calendar'[Date] ) = MIN ( OB[CutOffDate] ),
        0,
        SUM ( OB[OrderValue] )
    ),
    USERELATIONSHIP ( OB[OrderDate], 'Calendar'[Date] ),
    FILTER ( OB, OB[ShipDate] <= OB[CutOffDate] )
)

Running_total_within_time_periods

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.