Forum Discussion
Calculate average
To calculate the average days it takes for a name_id to change phase, you can follow these steps:
First, you need to identify the names that changed phases. You can do this by grouping the table by Name id and counting the number of distinct phases. If the count is greater than 1, it means the name changed phase.
Next, you can filter the table to include only the rows where the name changed phase.
For each name_id that changed phase, you need to calculate the number of days it took to change phase. To do this, you can use the DATEDIFF function to calculate the difference between the dates for the first and last row for each name_id.
Finally, you can calculate the average days it took for each name_id to change phase.
Here's the DAX code to accomplish this:
This code assumes your table is named 'Table', and the columns are named 'Name id', 'name_id_phase', and 'Date'. The result will be the average number of days it took for each name_id to change phase, only considering the names that are no longer in the previous phase.
Thank you for your answer.
Unfortunately it returns an error:
A single value for column 'name_id_phase' in table 'Table' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
Any ideas?