Forum Discussion
Anonymous
5 years agoNot applicable
Calculate Table
Hi guys. I'm trying to transform the following table: Ticket Open Close Age abc 01/jan 10/jan 10 def 01/jan 01/fev 32 ghi 01/jan 10/fev 41 jkl 01/jan 10/mar 70 ...
- Anonymous5 years ago
Hi Anonymous ,
1.My sample data is this.
Ticket
Age
Open
Close
abc
10
01/Jan
10/Jan
def
32
01/Jan
01/Feb
ghi
41
01/Jan
10/Feb
jkl
70
01/Jan
10/Mar
2.Create calculated columns to get Open date and Close date.
OpenDate = VAR month = SWITCH ( RIGHT ( 'Table'[Open], 3 ), "Jul", 7, "Aug", 8, "Sep", 9, "Oct", 10, "Nov", 11, "Dec", 12, "Jan", 1, "Feb", 2, "Mar", 3, "Apr", 4, "May", 5, "Jun", 6 ) RETURN DATE ( 2020, month, LEFT ( 'Table'[Open], 2 ) )CloseDate = VAR month = SWITCH ( RIGHT ( 'Table'[Close], 3 ), "Jul", 7, "Aug", 8, "Sep", 9, "Oct", 10, "Nov", 11, "Dec", 12, "Jan", 1, "Feb", 2, "Mar", 3, "Apr", 4, "May", 5, "Jun", 6 ) RETURN DATE ( 2020, month, LEFT ( 'Table'[Close], 2 ) )3.Create a calendar table.
Dates = ADDCOLUMNS ( CALENDAR ( DATE ( 2020, 1, 1 ), DATE ( 2020, 12, 31 ) ), "day", DAY ( [Date] ), "Period", DAY ( [Date] ) & "/" & FORMAT ( [Date], "mmm" ) )4.Create a new table which is a combination and filtering of the previous two tables.
NewTable = SUMMARIZE ( ADDCOLUMNS ( FILTER ( CROSSJOIN ( 'Dates', 'Table' ), [Date] <= [CloseDate] && [Date] >= [OpenDate] && [day] = 1 ), "Days by Month", IF ( EOMONTH ( [Date], 0 ) < [CloseDate], DAY ( EOMONTH ( [Date], 0 ) ), DAY ( [CloseDate] ) ) ), [Ticket], [Period], [Days by Month] )You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
5 years agoSuper User