Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello everyone,
I have data that looks like this:
Identifier | Start Date | End Date | Usage Value |
ABCF1234 | 1/01/2015 | 28/02/2015 | 387 |
AFDV1345 | 1/01/2015 | 12/01/2015 | 234 |
AFDV1345 | 13/01/2015 | 31/01/2015 | 423 |
What I need to do is to have monthly values for each identifier, but the non-uniform start and end dates are giving me a bit of a headache. Ideal output would look like this:
Identifier | Month | Usage Value |
ABCF1234 | Jan-15 | 200 |
ABCF1234 | Feb-15 | 187 |
AFDV1345 | Jan-15 | 657 |
I realise this would be an estimation, but I just cant figure out a way to do this. I was thinking something along the lines of getting an avg daily value, but I have no idea how I would group those values into months.
Has anybody dealt with this kind of data before? Any help would be much appreciated.
Cheers
Solved! Go to Solution.
Hi @MT
I think this might be getting close
Table = GROUPBY( FILTER( CROSSJOIN( -- Create and on the fly calendar table with a month column ADDCOLUMNS( CALENDARAUTO(), "Month",FORMAT([Date],"MMM-YY") ), -- Add a column to our base table that adds an average daily value ADDCOLUMNS( 'Table1', "Averate Usage Per Day", DIVIDE( 'Table1'[Usage Value], DATEDIFF( 'Table1'[Start Date], 'Table1'[End Date],DAY ) ) ) ), 'Table1'[Start Date] <= [Date] && 'Table1'[End Date] >= [Date] ), -- Perform the actual grouping here -- -- So Group by -- [Identifier], [Month], -- Now sum up the Average daily usage for the above groupings -- "Usage Value", SUMX( CURRENTGROUP(), [Averate Usage Per Day] ) )
If I run this over your sample data I get the following result
Hi @MT,
Have you tried the solution provided by @Phil_Seamark above? Does it work in your scenario? If it works, could you accept it as solution to close this thread?
If you still have any question on this issue, feel free to post here.
Regards
Hi @MT
I think this might be getting close
Table = GROUPBY( FILTER( CROSSJOIN( -- Create and on the fly calendar table with a month column ADDCOLUMNS( CALENDARAUTO(), "Month",FORMAT([Date],"MMM-YY") ), -- Add a column to our base table that adds an average daily value ADDCOLUMNS( 'Table1', "Averate Usage Per Day", DIVIDE( 'Table1'[Usage Value], DATEDIFF( 'Table1'[Start Date], 'Table1'[End Date],DAY ) ) ) ), 'Table1'[Start Date] <= [Date] && 'Table1'[End Date] >= [Date] ), -- Perform the actual grouping here -- -- So Group by -- [Identifier], [Month], -- Now sum up the Average daily usage for the above groupings -- "Usage Value", SUMX( CURRENTGROUP(), [Averate Usage Per Day] ) )
If I run this over your sample data I get the following result
User | Count |
---|---|
98 | |
90 | |
82 | |
73 | |
67 |
User | Count |
---|---|
115 | |
102 | |
98 | |
71 | |
67 |