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.
I have a data frame/Table as this:
DateStart; DateEnd; Group_Var; Price; Amount 2017-01-01; 2017-12-31; A; 9; 5 2017-06-01; 2017-12-31; A; 4; 10 2017-01-01; 2017-12-31; B; 5; 5 2017-06-01; 2017-12-31; B; 9; 1
I want a new table where I want to do the calculation:
DateEnd - DateStart (in hours) * Price * Amount or : Group_var A; 9 * 5 * 8760 + 4 * 10 * 5137 = 599680 Group_var B; 5 * 5 * 8760 + 9 * 1 * 5137 = 265233
So, end result is:
Group_var; Sum_Price_Over_Time A; 599680 B; 265233
I've figured out the
SUMMARIZE('Table' ;'Table' [Group_Var];"Value"; SUM('Table'[Price]))
But I am not sure how I can do the time diff and I get and error if I try to:
SUM(Price * Value)
Solved! Go to Solution.
Hey,
basically a measure like this, should work
Measure = CALCULATE( SUMX( 'Table1' ,DATEDIFF('Table1'[DateStart],'Table1'[DateEnd],HOUR)*'Table1'[Price]*'Table1'[Amount] ) )
But maybe you have to trick the DATEDIFF() a little by adding some extra hours. Depending on what the start and end date represents. Meaning: are 2017-01-01 to 2017-01-02 24hours or 48
Hope this is what you are looking for
Regards
Tom
Hey,
basically a measure like this, should work
Measure = CALCULATE( SUMX( 'Table1' ,DATEDIFF('Table1'[DateStart],'Table1'[DateEnd],HOUR)*'Table1'[Price]*'Table1'[Amount] ) )
But maybe you have to trick the DATEDIFF() a little by adding some extra hours. Depending on what the start and end date represents. Meaning: are 2017-01-01 to 2017-01-02 24hours or 48
Hope this is what you are looking for
Regards
Tom
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 |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |