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

Calculate how many standing orders per week and their value given set frequency

Hi,

 

I would like some help to calculate future trends of standing orders given each one has a set frequency, different start dates and amount. For example the table below

 

ContractStart dateFrequency (days)Value
123ABC01/06/2021         28£100
456DEF22/06/2021          7£50

 

So each week will provide information on how many standing order contracts fall within that week and their total values. I.e.

Week commencingNumber of standing ordersTotal value
31/05/20211£100
07/06/202100
14/06/202100
21/06/20211£50
28/06/20212£150
05/07/20211

£50

 

And so on until a set date, say 31/03/2022.

3 REPLIES 3
PaulOlding
Solution Sage
Solution Sage

Depending on what your data volumes are and performance requirements you should consider creating a 'Standing Order Payments' table that will list out the individual dates based on Start Date and Frequency.  You could use Power Query to do this.  The table would look like:

ContractValueStanding Order Date
123ABC10001/06/2021
456DEF5022/06/2021
123ABC10029/06/2021
456DEF5029/06/2021
456DEF5006/07/2021
456DEF5013/07/2021

 

You can then join a date table that includes 'Week Starting Date' column to Standing Order Date and you're ready to count and sum your standing orders.

 

It's possible to get your example result without doing that.  These measures includes a GENERATE function call which essentially creates the table above on the fly.

These measures also use a date table, but disconnected from the Standing Orders table:

PaulOlding_0-1624358411688.png

 

Number of standing orders =
VAR _EndDate = DATE(2022,3,31)
VAR _StandingOrderPayments =
GENERATE(
    'Standing Orders',
    FILTER('Date',
        'Date'[Date] >= 'Standing Orders'[Start Date]
        && 'Date'[Date] <= _EndDate
        && MOD(INT('Date'[Date] - 'Standing Orders'[Start Date]), 'Standing Orders'[Frequency]) = 0
        )
    )
VAR _Result = COUNTROWS(_StandingOrderPayments)
RETURN
_Result
 
Total Value =
VAR _EndDate = DATE(2022,3,31)
VAR _StandingOrderPayments =
GENERATE(
    'Standing Orders',
    FILTER('Date',
        'Date'[Date] >= 'Standing Orders'[Start Date]
        && 'Date'[Date] <= _EndDate
        && MOD(INT('Date'[Date] - 'Standing Orders'[Start Date]), 'Standing Orders'[Frequency]) = 0
        )
    )
VAR _Result = SUMX(_StandingOrderPayments, 'Standing Orders'[Value])
RETURN
_Result

 

Yes I think a Standing Orders Payment table may be a good idea. Do you know how I would use Power Query to create such a table using the Start dates and Frequency already in the Contracts table?

Power Query's not my speciality.  I expect they'll be others in the forum who can do that.

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