Forum Discussion
One-Dash
4 years agoFrequent Visitor
How to write Dax for weekly tracking and back log analysis
Hello! I'm having trouble to DAX the scenario below i have 2 tables 1- Date table - 2 Request Table - it tracks a Request from when it was recieved -> assigne to person ->...
- Anonymous4 years ago
Hi One-Dash ,
1. Create a new table for the X-axis:
For X-axis = {"Total Requests for the week","Start to QC","QC to Resolved" }2. Get Year and Week in Dates table:
Dates = DISTINCT ( SELECTCOLUMNS ( CALENDAR ( MIN ( 'Table1'[Received Date] ), MAX ( 'Table1'[Resolved Date] ) ), "Year", YEAR ( [Date] ), "Month", MONTH ( [Date] ), "Week", WEEKNUM ( [Date], 2 ), "Year Week", YEAR ( [Date] ) & "/Week" & WEEKNUM ( [Date], 2 ) ) )3.Then create a measure:
Measure = VAR _request = CALCULATE ( DISTINCTCOUNT ( Table1[Request ID] ), FILTER ( 'Table1', YEAR ( [Received Date] ) = MAX ( 'Dates'[Year] ) && WEEKNUM ( [Received Date], 2 ) = MAX ( 'Dates'[Week] ) ) ) VAR _qc = CALCULATE ( DISTINCTCOUNT ( Table1[Request ID] ), FILTER ( 'Table1', YEAR ( [Sent to QC date] ) = MAX ( 'Dates'[Year] ) && WEEKNUM ( [Sent to QC date], 2 ) = MAX ( 'Dates'[Week] ) ) ) VAR _resolved = CALCULATE ( DISTINCTCOUNT ( Table1[Request ID] ), FILTER ( 'Table1', YEAR ( [Resolved Date] ) = MAX ( 'Dates'[Year] ) && WEEKNUM ( [Resolved Date], 2 ) = MAX ( 'Dates'[Week] ) ) ) RETURN SWITCH ( MAX ( 'For X-axis'[Type] ), "Total Requests for the week", _request, "Start to QC", _qc, "QC to Resolved", _resolved )Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
4 years agoNot applicable
Hi One-Dash ,
1. Create a new table for the X-axis:
For X-axis = {"Total Requests for the week","Start to QC","QC to Resolved" }
2. Get Year and Week in Dates table:
Dates =
DISTINCT (
SELECTCOLUMNS (
CALENDAR ( MIN ( 'Table1'[Received Date] ), MAX ( 'Table1'[Resolved Date] ) ),
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"Week", WEEKNUM ( [Date], 2 ),
"Year Week",
YEAR ( [Date] ) & "/Week"
& WEEKNUM ( [Date], 2 )
)
)
3.Then create a measure:
Measure =
VAR _request =
CALCULATE (
DISTINCTCOUNT ( Table1[Request ID] ),
FILTER (
'Table1',
YEAR ( [Received Date] ) = MAX ( 'Dates'[Year] )
&& WEEKNUM ( [Received Date], 2 ) = MAX ( 'Dates'[Week] )
)
)
VAR _qc =
CALCULATE (
DISTINCTCOUNT ( Table1[Request ID] ),
FILTER (
'Table1',
YEAR ( [Sent to QC date] ) = MAX ( 'Dates'[Year] )
&& WEEKNUM ( [Sent to QC date], 2 ) = MAX ( 'Dates'[Week] )
)
)
VAR _resolved =
CALCULATE (
DISTINCTCOUNT ( Table1[Request ID] ),
FILTER (
'Table1',
YEAR ( [Resolved Date] ) = MAX ( 'Dates'[Year] )
&& WEEKNUM ( [Resolved Date], 2 ) = MAX ( 'Dates'[Week] )
)
)
RETURN
SWITCH (
MAX ( 'For X-axis'[Type] ),
"Total Requests for the week", _request,
"Start to QC", _qc,
"QC to Resolved", _resolved
)
Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.