Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I am using the data model in Excel, not Power BI. And, I am brand new to DAX.
I have a data table and a calendar table.
The purpose of the report I am building is to track backlogged (overdue) cases.
Each case has the following dates and each of these fields has a relationship with the date table:
- Date Sent to Region
- Due By
- Entrance Date
- Status Change Date
Each case has a Status of either Open or Closed.
A case investigated timely would be: Status = Closed AND the Entrance Date <=Due By date.
The exception to this statement is that some cases are closed without an Entrance Date. In these instance we use the Status Change Date.
The goal is to create a monthly backlog table with a line chart. For example, how many cases were overdue in January 2024?
With the help of other users here, I created the following measure. Unfortunately, it produces a blank and not the count I need:
Backlog:=CALCULATE(
COUNTROWS(RS_Cases),
USERELATIONSHIP(Date_Table[Date], RS_Cases[Due By]),
FILTER(
ALL(RS_Cases),
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN") ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date]))
)
)
I tried troubleshooting by breaking down each of the filters, and they all produce a blank. Whittled down to the minimum and it still produces a blank:
Copy of Backlog:=CALCULATE(
COUNTROWS(RS_Cases),
USERELATIONSHIP(Date_Table[Date], RS_Cases[Due By]),
FILTER(RS_Cases,RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN")
)
If I take out the "USERELATIONSHIP", then I get a semantic error that FILTER has been used in a True False expression:
Copy of Backlog:=CALCULATE(
COUNTROWS(RS_Cases),
FILTER(RS_Cases,RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN")||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date]))
)
I have been working on this for weeks now and have hit a wall. If it helps to explain what I want the measure to do, this is an Excel formula I created that calculates the results I need. It is based on a table with columsn for Month & Backlog Count. But it is not a dynamic solution and not the solution I am looking for:
=SUM(COUNTIFS(RS_Cases[Due By],"<="&EOMONTH([@Month]&1,0),RS_Cases[Entrance Date],">"&EOMONTH([@Month]&1,0)),
COUNTIFS(RS_Cases[Due By],"<="&EOMONTH([@Month]&1,0),RS_Cases[Entrance Date],"",RS_Cases[Status],"CLOSED",RS_Cases[Status Change Date],">"&EOMONTH([@Month]&1,0)),
COUNTIFS(RS_Cases[Due By],"<="&EOMONTH([@Month]&1,0),RS_Cases[Status],"OPEN"))
If more information is needed, please let me know. In the meantime, thank you in advance for getting this far into this post and your reply.
Solved! Go to Solution.
Thank you for your response. Late yesterday, I discovered if I removed the USERRELATIONSHIP function from the statement below, I achieved the result I was after:
Backlog:=CALCULATE(
COUNTROWS(RS_Cases),USERELATIONSHIP(Date_Table[Date], RS_Cases[Due By]),
FILTER(
ALL(RS_Cases),
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN") ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date]))
)
)
Hi @Txtcher ,
Could you please provide sample data? It will be better If there is a pbix file(does not contain sensitive data). This will help us reproduce the problem and provide solution.
Best regards,
Mengmeng Li
Thank you for your response. Late yesterday, I discovered if I removed the USERRELATIONSHIP function from the statement below, I achieved the result I was after:
Backlog:=CALCULATE(
COUNTROWS(RS_Cases),USERELATIONSHIP(Date_Table[Date], RS_Cases[Due By]),
FILTER(
ALL(RS_Cases),
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Status]="OPEN") ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && RS_Cases[Entrance Date]>Max(Date_Table[Date])) ||
(RS_Cases[Due By]<=MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status]="CLOSED" && RS_Cases[Status Change Date]>MAX(Date_Table[Date]))
)
)
Hi @Txtcher - can you try below logic with both userrelationship function and filter:
Backlog :=
CALCULATE(
COUNTROWS(RS_Cases),
USERELATIONSHIP(Date_Table[Date], RS_Cases[Due By]),
FILTER(
RS_Cases,
(RS_Cases[Due By] <= MAX(Date_Table[Date]) && RS_Cases[Status] = "OPEN") ||
(RS_Cases[Due By] <= MAX(Date_Table[Date]) && NOT(ISBLANK(RS_Cases[Entrance Date])) && RS_Cases[Entrance Date] > MAX(Date_Table[Date])) ||
(RS_Cases[Due By] <= MAX(Date_Table[Date]) && ISBLANK(RS_Cases[Entrance Date]) && RS_Cases[Status] = "CLOSED" && RS_Cases[Status Change Date] > MAX(Date_Table[Date]))
)
)
I hope this works
Proud to be a Super User! | |
Unfortunately, I am still getting a blank result.
User | Count |
---|---|
81 | |
75 | |
74 | |
42 | |
36 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |