Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello to everyone !
I would like to create a report that shows statistics concerning opened, closed and active cases retrieved from CRM dynamics 365 based on weekly time range.
In particular, I would like to create a chart (line or clustered bar) that shows, for each week for a selected year, the number of opened tickets and the number of closed tickets, like the following one:
In order to do this, from a direct query issued on CRM database, I created a table 'AllCases' that contains all columns (including the custom ones). Then I created a calendar table in power BI as follow:
Then I created two custom columns in 'AllCases' table:
CreateDate = DATE(YEAR('AllCases'[createdon]),MONTH('AllCases'[createdon]),DAY('AllCases'[createdon]))EndDate = IF(ISBLANK('AllCases'[closedon]),BLANK(),DATE(YEAR('AllCases'[closedon]),MONTH('AllCases'[closedon]),DAY('AllCases'[closedon])))Activetickets = CALCULATE(COUNTROWS('AllCases'),FILTER('AllCases','AllCases'[statuscodename]="Not Scheduled" || 'AllCases'[statuscodename]="In Progress" || 'AllCases'[statuscodename]="Pending Customer - Information" || 'AllCases'[statuscodename]="Pending Customer - On Hold" || 'AllCases'[statuscodename]="Pending Internal - Development" || 'AllCases'[statuscodename]="Pending Internal - Evaluation"))ClosedTickets = CALCULATE(COUNTA(AllCases[ticketnumber]),FILTER('AllCases','AllCases'[statuscodename]="Closed"||'AllCases'[statuscodename]="Problem Solved"||'AllCases'[statuscodename]="Canceled"||'AllCases'[statuscodename]="Duplicated"||'AllCases'[statuscodename]="Not A Bug"||'AllCases'[statuscodename]="Obsolete (Archived)"||'AllCases'[statuscodename]="Out of Scope"))Opentickets = CALCULATE(COUNTROWS('AllCases'),
FILTER('AllCases', ('AllCases'[createdon]<= LASTDATE('Date'[Date])
&& 'AllCases'[createdon]>= FIRSTDATE('Date'[Date]))))Hi @_Roberto_ ,
We can try to use the following measures to meet your requirement:
Activetickets =
VAR lastDate =
MAX ( 'Date'[Date] )
RETURN
CALCULATE (
COUNTROWS ( 'AllCases' ),
FILTER (
ALLSELECTED ( 'AllCases' ),
AND (
AND ( 'AllCases'[endDate] > lastDate, 'AllCases'[startDate] <= lastDate ),
'AllCases'[statuscodename] = "Not Scheduled"
|| 'AllCases'[statuscodename] = "In Progress"
|| 'AllCases'[statuscodename] = "Pending Customer - Information"
|| 'AllCases'[statuscodename] = "Pending Customer - On Hold"
|| 'AllCases'[statuscodename] = "Pending Internal - Development"
|| 'AllCases'[statuscodename] = "Pending Internal - Evaluation"
)
)
)ClosedTickets =
CALCULATE (
COUNTA ( AllCases[ticketnumber] ),
FILTER (
ALLSELECTED ( 'AllCases' ),
AND (
'AllCases'[endDate] IN FILTERS ( 'Date'[Date] ),
'AllCases'[statuscodename] = "Closed"
|| 'AllCases'[statuscodename] = "Problem Solved"
|| 'AllCases'[statuscodename] = "Canceled"
|| 'AllCases'[statuscodename] = "Duplicated"
|| 'AllCases'[statuscodename] = "Not A Bug"
|| 'AllCases'[statuscodename] = "Obsolete (Archived)"
|| 'AllCases'[statuscodename] = "Out of Scope"
)
)
)Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you @v-lid-msft , I used measures that you suggested (I just modified "lastDate" in "lastDate1" because "lastDate" is a key word in power BI). But numbers diplayed in the chart are still not correct.
I'm preparing a excel file so I can give you an example of real numbers retrieved from CRM.
Hi @_Roberto_ ,
After checking the visual, we found the error reason in my formula, when using weeknumber, it contains same week in multi years, can you put a filter year = 2018 and see if the formula can return the expected result?
Edited, Sorry I did not see the selected year in the origin post, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please do not use any real data. Please upload your files to One Drive and share the link here.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-lid-msft thank you again for your support.
I am sorry for the late reply, but maybe I found the issue.
As I said data are retreived from a direct query from CRM dynamics database.
In CRM I configured a workflow that is filling the column "closedon" by performing a copy of the value of "modifiedon" when the status reason of the a ticket is changed in "closed".
So, I think that is matter of timing because probably the workflow is not syncronizing data in short time.
I found this issue by performing an export of CRM data in the excel file (sorry if I didn't sent yet). Using the excel file all charts are correct.
Hi @_Roberto_ ,
So when the measure run, the enddate may be blank? If the enddate will be filled several times one day, do you have a logic about how to deal with this empty date? We can modify the formula to meet your new logic.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |