Forum Discussion
Count dates between two dates within the same column
- 6 years ago
Hi, Yggdrasill
You may modify 'var _date = SELECTEDVALUE('Calendar'[Date])' as 'var _date = MAX('Calendar'[Date])' and make other codes unchanged.
CountValue = var _date = MAX('Calendar'[Date]) var _status = SELECTEDVALUE(Test[Status]) var tab = SUMMARIZE( ALLSELECTED('Table'), 'Table'[Case], "MaxDate", var c = [Case] return CALCULATE( MAX('Table'[Date]), FILTER( ALLSELECTED('Table'), 'Table'[Case] =c&& 'Table'[Date]<=_date ) ) ) var newtab = ADDCOLUMNS( tab, "Status", var c = [Case] var md = [MaxDate] return MAXX( FILTER( ALLSELECTED('Table'), 'Table'[Case] = c&& 'Table'[Date] = md ), [Status to] ) ) var result = COUNTROWS( FILTER( newtab, [Status] = _status ) ) return IF( ISBLANK(result), 0, result )Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi You could just use the category as value on your visual and select its aggregation as count . Alternatively create a new measure as
That won't work as I need to count all the dates between the two dates. Your suggestion will only count for the dates registered in the transaction table - Hence, I need to count the dates in the Calendar table in order to have the value 1 for each Category that falls between the two dates.
You can look at this model as a demo for a Ticket system where the status of the ticket for company A, B, C... can have the value Open, Pending, In Order and Closed where each status has it's own date.
I need to be able to count all Pending orders from any date I choose to view at any given time and even filter it by company A, B, C etc