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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Morten_DK
Helper I
Helper I

Accounts receivable montly

I have a table for accounts receivables (payables by customers) that contains:

 

"Posting date"      "Closed at date"      "Due date"      "Customer number"       "Amount"

2021-09-01            2021-12-15            2021-12-01         ABC1                           100

 

In the above example I would like to calculate the montly receivables so:

September = 100

October = 100

November = 100

end of December = 0

 

So I need to calculate a measure that states that if the date from the date table is higher than or qual to the posting date from receivables table and also closing date is higher than date from data table then show receivables amount. 

 

I have tried with the following measure:

Outstanding Invoices =
var StartDate = calculate(Max(Receivables[Posting Date]),all('Date'))
var ClosedDate = calculate(Max(Receivables[Closed at Date]),all('Date'))

RETURN
CALCULATE (
Receivables[Invoiced Receivables],
'Date'[Date] >= StartDate && 'Date'[Date] <= ClosedDate
)
 
That returns the correct receivables amount but on all months is the same. There is no relationship between receivables table and date table
1 ACCEPTED SOLUTION

Hi, @Morten_DK 

 

You can add a condition to filter Customer number in the measure.

Measure = 
IF (
    MAX ( 'Date'[Date] ) >= MAX ( 'Table'[Posting date] )
        && MAX ( 'Date'[Date] ) < MAX ( 'Table'[Closed at date] ),
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        FILTER (
            ALL ( 'Date' ),
            [Date].[Month] <= MAX ( 'Table'[Closed at date].[Month] )
        ),FILTER(ALL('Table'),[Customer number]=MAX('Table'[Customer number]))
    ),
    BLANK ()
)

vzhangti_0-1639708148646.pngvzhangti_1-1639708180103.png

 

If the method I provided above can't solve your problem, what's your expected result? Can you provide an example diagram of your desired outcome?

 

Best Regards,

Community Support Team _Charlotte

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

7 REPLIES 7
v-zhangti
Community Support
Community Support

Hi, @Morten_DK 

 

You can take a look at the following methods, hoping to solve your problem.

Create a new date table.

Date = CALENDAR(DATE(2021,8,1),DATE(2021,12,31))
Measure =
IF (
    MAX ( 'Date'[Date] ) >= MAX ( 'Table'[Posting date] )
        && MAX ( 'Date'[Date] ) < MAX ( 'Table'[Closed at date] ),
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        FILTER (
            ALL ( 'Date' ),
            [Date].[Month] <= MAX ( 'Table'[Closed at date].[Month] )
        )
    ),
    BLANK ()
)

Max ('date '[date]) is the date that can be selected on the right side of the date slicer.

 

vzhangti_1-1639640012018.pngvzhangti_0-1639639979422.png

 

Best Regards,

Community Support Team _Charlotte

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

Thanks!

 

That seems to be working on individual order numbers, but if I take an entire month without filtering on particular orders, then the sum for the month is blank. If I drill down to order numbers then I get the correct value per order, but not on month level, that is still blank.

 

Is there a way to force the calculation on row level and then sum up, if that is the cause of the problem in the first place? 

Hi, @Morten_DK 

 

You can add a condition to filter Customer number in the measure.

Measure = 
IF (
    MAX ( 'Date'[Date] ) >= MAX ( 'Table'[Posting date] )
        && MAX ( 'Date'[Date] ) < MAX ( 'Table'[Closed at date] ),
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        FILTER (
            ALL ( 'Date' ),
            [Date].[Month] <= MAX ( 'Table'[Closed at date].[Month] )
        ),FILTER(ALL('Table'),[Customer number]=MAX('Table'[Customer number]))
    ),
    BLANK ()
)

vzhangti_0-1639708148646.pngvzhangti_1-1639708180103.png

 

If the method I provided above can't solve your problem, what's your expected result? Can you provide an example diagram of your desired outcome?

 

Best Regards,

Community Support Team _Charlotte

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

 

parry2k
Super User
Super User

@Morten_DK is it assumption based rule or there is data to back up this logic?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thats a logic.

 

When an invoice is posted (posting date) it stays in the accounts receivable until it is paid (closed at date).

 

The following works apart from not stopping at Closed at date:

 

Outstanding Invoices =
CALCULATE (
Receivables[Invoiced Receivables],
FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
)

 

if I modify it to:

Outstanding Invoices =
CALCULATE (
Receivables[Invoiced Receivables],
FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) &&'Date'[Date] <= max(Receivables[Closed_at_date])  )
)

Then I don't get all the months in between. 

parry2k
Super User
Super User

@Morten_DK what made December value to 0, what is the logic?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k that is because at end of december (31/12-2021) we are past "Closed at date" which means the outstanding amount has been paid, thus no outstanding anymore.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.