Forum Discussion

Nasus_'s avatar
Nasus_
Regular Visitor
3 years ago

Status as at date

Hello,

Looking for a bit of help with a measure to populate a line graph.

 

I have two tables;

 

FactOrder:

Which lists orders and their ID's with  a new record added each time an order changes status e.g.

 

OrderID

OrderStatus

OrderStatusDate

1

Closed

18/07/2023

1

Reopen

12/07/2023

1

Closed

02/07/2023

1

Open

29/06/2023

2

Closed

19/07/2023

2

Reopen

09/07/2023

2

Closed

01/07/2023

2

Open

20/06/2023

3

Open

21/06/2023

4

Closed

10/07/2023

4

Open

01/07/2023

5

Closed

19/07/2023

5

Reopen

13/07/2023

 

And DimReportingDate:
This lists Dates which are at the end of a reporting week e.g.

ReportWeekEnd

20/07/2023

20/07/2023

06/07/2023

29/06/2023

22/06/2023

15/06/2023


I'm looking to use these to populate a line graph which does a distinct count of OrderID that were Open or Reopen at the dates listed in DimReportingDate, however I've been going around in circles.

 

I was hoping to gain a bit of help or guidance here


an example of what this small subset would look like

 

2 Replies

  • Nasus_ , First have date table with choice of week ending date

    https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Power-BI-Turning/ba-p/1187482
    https://medium.com/chandakamit/cheat-sheet-any-weekdays-week-start-date-just-one-variable-apart-6b2e6f593958

     

    then you can have measure like

     

    calculate(distinctcount(Table[OrderID]), filter(Table, Table[OrderStatus] in {"Open", "Reopen"}))

     

    If this does not help
    Can you share sample output in table format? Or a sample pbix after removing sensitive data.

    • Nasus_'s avatar
      Nasus_
      Regular Visitor

      Hi, Many thanks for getting back to me and apologies for the delay. 

      Currently I already have a date table as described in my model which has a relationship with the column OrderStatusDate on FactOrder, below is a set of this. 

      DateDayReportWeekEnd
      20/07/202320/07/2023
      19/07/202320/07/2023
      18/07/202320/07/2023
      17/07/202320/07/2023
      16/07/202320/07/2023
      15/07/202320/07/2023
      14/07/202320/07/2023
      13/07/202313/07/2023
      12/07/202313/07/2023
      11/07/202313/07/2023
      10/07/202313/07/2023
      09/07/202313/07/2023
      08/07/202313/07/2023
      07/07/202313/07/2023
      06/07/202306/07/2023
      05/07/202306/07/2023
      04/07/202306/07/2023
      03/07/202306/07/2023
      02/07/202306/07/2023
      01/07/202306/07/2023
      30/06/202306/07/2023
      29/06/202329/06/2023
      28/06/202329/06/2023
      27/06/202329/06/2023
      26/06/202329/06/2023
      25/06/202329/06/2023
      24/06/202329/06/2023
      23/06/202329/06/2023
      22/06/202322/06/2023
      21/06/202322/06/2023
      20/06/202322/06/2023
      19/06/202322/06/2023
      18/06/202322/06/2023
      17/06/202322/06/2023
      16/06/202322/06/2023
      15/06/202315/06/2023

       

      To give further context here is an example of one order that moves through status's at different dates on the FactOrder Table

      OrderIDOrderStatusStatusGroupingDateStatusChangedTimeText
      80691Closed27/08/202210:26:35
      80691Open22/08/202220:29:28
      80691Reopen16/08/202211:42:55


      So I would need to count this as a value of one for the report weeks where this was at Open or Reopen and any following reporting weeks until its changed to closed, bare in mind orders can be opened and reopened after closure, and can change status' multilple times per reporting week so it needs to take into account the latest one as per that reporting date. 



      Hopefully that makes sense.