Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello everyone,
I have a challenging question. I have the table as below, with open date, closed date, and status...
My goal is to show a count of items that remain open during each month and create a graph like below:
So far the best approach I can think of is to subtract the closed date from the open date and create a matrix with a value of 1 for each month in between (screenshot below). BUT I can't figure out how to do that in DAX. Can anyone guide me here? or recommend a better solution?
Hi,
Thanks for the solution @lbendlin provided, and i want to offer some more information for user to refer to.
hello @aaa12 , based on your descriotion, you want to calculate the open items based on each month, you can refer to the following solution.
Sample data
And i have a Calendar table, there is a 1:N relatinship relationship between tables, the key columns are open column in data table and date column in calendar table.
1.In data table create a calculated column
ClosedDate = IF([Closed]<[Open],MAXX('Calendar',[Date]),[Closed])
2.Create a measure
Open_count =
VAR _add =
CALCULATETABLE (
ADDCOLUMNS (
'Table',
"Flag",
VAR a =
CALENDAR ( [Open], [ClosedDate] )
VAR b =
VALUES ( 'Calendar'[Date] )
RETURN
COUNTROWS ( INTERSECT ( a, b ) )
),
CROSSFILTER ( 'Calendar'[Date], 'Table'[Open], NONE )
)
RETURN
COUNTROWS ( FILTER ( _add, [Flag] > 0 ) )
Then create a visual, and put the date column and the measure to the visual.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hello - thank you for the response. Unfortunately the totals were different than actuals using the proposed solution. I went with somewhat of an inelloquent solutions by creating separate columns to evaluate each time period and then graphing it together. It works but as mentioned before, it's not so elloquent.
Thank you again.
@lbendlin : Thank you...I wasn't able to reproduce it...
1. Do not use fake dates. Leave the close date empty and use COALESCE or a filter. (DONE)
2. You are showing by month. Does it mean you want to count which tickets were closed on any day of the month? (YES, just by month)
3. use a calendar table. (DONE)
My results....it seems the open and closed totals cancel each other out...
My measures:
Closed
Open
Running Total
My modeling relationships:
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
34 | |
17 | |
12 | |
11 | |
9 |
User | Count |
---|---|
45 | |
25 | |
16 | |
14 | |
14 |