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
DevonVanDam
Helper I
Helper I

Accounts Receivable: what measure do I need to see how much is invoiced & received in a certain week

Hi guys,

 

I have a dataset of accounts receivable items 01.01.2019 - 30.09.2019. The data includes things like document date - due date - clearing date. How can I build a table that shows what is open in a certain week based on the document date and the clearing date. I also want to see how much is cleared (=received) in that week. So there must be a split between open items and cleared items in that week. If something is cleared it shouldn't show anymore in the following week. 

 

So i also want to add a chichlet slicer with all weeks of the year. I know how this works. Only not sure about what measures are required. I am decent with Power BI - but this is a next step for me. I am not familair with this.

 

I want to see this for a certain week:

Row 1. Received (cleared items in that week based on clearing date) -> 5K example

Row 2. Invoiced (new invoices created in that week based on document date) -> 10K example

Row 3. Open items from prior weeks (based on document & clearing date (or not cleared)) -> 50K example

 

If I need to add more information - please let me know - apologies in advance in that case.

 

Thanks,

Devon 

1 ACCEPTED SOLUTION

Alright, I have refined the code a little, based on your values, so for the number of open documents it now looks like this:

Open documents =
VAR _maxDate =
    MAX ( vDate[Date] )
VAR _minDate =
    MIN ( vDate[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Document Number] );
        FILTER (
            'Table';
            'Table'[Clearing date] > _minDate
                && 'Table'[Document Date] < _maxDate
        )
    )
        + CALCULATE (
            DISTINCTCOUNT ( 'Table'[Document Number] );
            FILTER (
                'Table';
                ISBLANK ( 'Table'[Clearing date] )
                    && 'Table'[Document Date] < _maxDate
                    && _maxDate <= TODAY ()
            )
        )

A quick walkthrough of the code:
_minDate and _maxDate calculates the min and max date in the the current context. If you choose 1 week it will be the first and the last day of the week. If you choose a whole year, it will be the first and the last date of the year.

 

Next there is a part of code that starts with calculate. It counts the number of distinct document numbers which satisfy the following criteria:
Clearing date must be a later date than the first date in the current context.
Document date(*) must be an earlier date than the last date in the current context.

 

The table 'Table' will be filtered be these criterias, and the output will be number of distinct document numbers. With these criterias, when you select a spesific week, you will count all documents that were open at one point in that week. If was cleared on Wednesday, it counts as open that week. The nice thing about this definition is that if you select e.g. a whole year, you will see all documents that were open that year.

 

The second calculate-part handles documents which has no clearing date yet. This document will be counted according to these criterias:
Document date(*) must be an earlier date than the last date in the current context.

Last date in current context must be earlier or equal to todays date.

 

Hope this cleared things up a little for you. Here is the link to the power bi file: pbix

 

View solution in original post

6 REPLIES 6
sturlaws
Resident Rockstar
Resident Rockstar

Hi @DevonVanDam ,

great description of your problem, the only ting missing is a relevant sample dataset.

 

One way to solve your problem is by creating a date dimension without connections to your dataset table and create measures like this:

Uncleared documents =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[documentID] );
    FILTER (
        'Table';
        ISBLANK ( 'Table'[clearing date] )
            && 'Table'[due date] >= MIN ( vDate[Date] )
            && 'Table'[due date] <= MAX ( vDate[Date] )
    )
)

and

Cleared documents =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[documentID] );
    FILTER (
        'Table';
        'Table'[clearing date] >= MIN ( vDate[Date] )
            && 'Table'[clearing date] <= MAX ( vDate[Date] )
    )
)



sample report

These measures don't do anything for me. How can I show open items per selected week / year.

I am using a year chiclet slicer and a week chichlet slicer. So I want to see open items per week. It is an open item based on the clearing date versus the dates in that week / year selected. 

 

Can you help me further now you have seen my database @sturlaws ?

 

I don't really understand what the formules you mentioned are doing, how do I use them? 

Alright, I have refined the code a little, based on your values, so for the number of open documents it now looks like this:

Open documents =
VAR _maxDate =
    MAX ( vDate[Date] )
VAR _minDate =
    MIN ( vDate[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Document Number] );
        FILTER (
            'Table';
            'Table'[Clearing date] > _minDate
                && 'Table'[Document Date] < _maxDate
        )
    )
        + CALCULATE (
            DISTINCTCOUNT ( 'Table'[Document Number] );
            FILTER (
                'Table';
                ISBLANK ( 'Table'[Clearing date] )
                    && 'Table'[Document Date] < _maxDate
                    && _maxDate <= TODAY ()
            )
        )

A quick walkthrough of the code:
_minDate and _maxDate calculates the min and max date in the the current context. If you choose 1 week it will be the first and the last day of the week. If you choose a whole year, it will be the first and the last date of the year.

 

Next there is a part of code that starts with calculate. It counts the number of distinct document numbers which satisfy the following criteria:
Clearing date must be a later date than the first date in the current context.
Document date(*) must be an earlier date than the last date in the current context.

 

The table 'Table' will be filtered be these criterias, and the output will be number of distinct document numbers. With these criterias, when you select a spesific week, you will count all documents that were open at one point in that week. If was cleared on Wednesday, it counts as open that week. The nice thing about this definition is that if you select e.g. a whole year, you will see all documents that were open that year.

 

The second calculate-part handles documents which has no clearing date yet. This document will be counted according to these criterias:
Document date(*) must be an earlier date than the last date in the current context.

Last date in current context must be earlier or equal to todays date.

 

Hope this cleared things up a little for you. Here is the link to the power bi file: pbix

 

Hi @sturlaws ,

 

Thank you in advance for your help and reply! I follow your measure, only question please:

what is vDate[Date]. Am I supposed to make some kind of date file (Excel)? 

 

I have the below one, is that it? The 'Date' column?

DateDayInWeekDayOfMonthDayOfWeekName
1-1-201771Sunday
2-1-201712Monday
3-1-201723Tuesday
4-1-201734Wednesday
5-1-201745Thursday
6-1-201756Friday
7-1-201767Saturday
8-1-201778Sunday
9-1-201719Monday
10-1-2017210Tuesday

 

When someone asks for help without attaching a demo file or sample dataset, I usually create dummy dataset and report to make sure the solution I provide actually works. vDate is just the date table of such a report. Replace it with your own date table in the code

Posting DateDocument Date)Document NumberVendorAmount ƒ-LCClearing DocumentClearing dateReference (Acc. Doc. Header)Fiscal Year (Acc. Doc. Header)Fiscal period (Acc. Doc. Header)
26-6-201825-6-201816001200919963284,16160012009226-6-20186014347807 HV20186
26-6-201825-6-201816001200929963-284,16160012009226-6-20186014347807 HV20186
8-11-20181-11-2018160012017518384-97,1516001201768-11-201890854197 HV201811
8-11-20181-11-201816001201761838497,1516001201768-11-201890854197 HV201811
8-1-20188-1-2018240022421116686123,23240022455216-1-2018PR/11566 PV20181
8-1-20188-1-201824002242126996777,49240022446015-1-201890830452 PV20181
9-1-20189-1-2018240022427715062,12240022593819-2-201890830653 HV20181
9-1-201820-12-2017240022430610102-148,224002243069-1-201895197884 PV20181
10-1-201814-12-2017240022433317198-82,42240022433310-1-201880750C71Q PV20181
10-1-201810-1-20182400224334101025,67240022468318-1-20180028 PV20181
10-1-20189-1-20182400224343100881425,8524002314234-7-2018180000639 HV+PV20181
11-1-201818-12-201724002243776996-2777,63240022437711-1-201890826082 PV20181
11-1-201817-10-2017240022437813955-89,15240022437811-1-2018607305 PV20181
11-1-201811-1-2018240022441318719452,5240022441911-1-201895194465 PV20181
11-1-20183-1-20182400224414145558,3324002256028-2-2018626934 PV20181
11-1-201811-1-201824002244151871910,08240022442011-1-201895196465 HV20181
11-1-201816-11-20172400224418100882266,78  170029965 PV20181
11-1-201811-1-2018240022441918719-452,5240022441911-1-201895194465 PV20181
11-1-201811-1-2018240022442018719-10,08240022442011-1-201895196465 HV20181
12-1-201824-8-20172400224438150-836,18240022443812-1-201890820043 HV+PV20181

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.