Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
96 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
88 | |
63 |