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.
OK I've got a running total measure that works fairly well sort of.
Metric Cumulative = calculate( sum('Raw Data'[Component])/[Average Customers], Filter( Allselected('Raw Data'), 'Raw Data'[Start Date]<=max('Raw Data'[Start Date]) ) )
However, when I put this on a line graph, with Year in the legend and Start Date on the axis (but no year or quarter option, straight down to the months), it plots it somewhat strangely. The 2013 data starts at zero and accumulates just fine. But the 2014 data starts in January at the same point that the 2013 data ended at. So the accumulation doesn't start over for each category of the legend. What am I doing wrong?
Here's what it looks like currently:
And here's what I want it to look like:
Solved! Go to Solution.
OK turns out this was way easier than I was making it. Instead of messing with the formula and doing everything 'by force', there is a Quick Measure for Year to Date. I thought at the time I was playing with it that the YTD would only work for data in the current year, but it will actually work for multiple years. I was able to add a YTD version of the metric and it worked perfectly and gave me the exact graph I was looking for there.
@soldstatic,
Based on your first screenshot and your sample data, the Metric Cumulative value for January of 2014, 2015, 2016,2017 and 2018 years don't equal to 0, do you want to set the Metric Cumulative value to be 0? If so, could you please share more data of "Raw data" table for us to test?
Regards,
Lydia
Right, January wouldn't be equal to 0, but Jan 1st of the year at midnight would be 0.
Basically my data is very granular, and I have rows of data for almost every hour of every day. I would need it to reset to zero exactly at midnight, but even by 1am on new year's day I'll probably have data. Below is a moderately anonymized version of the table. Dates and stuff are the same. I have calculated columns that don't show here for Year(start date), month(start date), day(Start date). Also have Year&Month (ie 201804), and year month territory (ie 201804A). The customer table also has year month territory column (ie 201804A) which is what the relationship is based on.
ID | Start Date | End Date | Status | Metric Component 2 | Length | Metric Component | Territory | C# | UODID | Cause | View | Source |
15598583 | 4/1/13 0:00 | 4/1/13 14:46 | CMP | 0 | 886.4166667 | 0 | A | 839.2634767 | 350.295675 | Outside Factor | PM | 1.7 |
15598584 | 4/1/13 0:00 | 4/1/13 18:23 | CMP | 0 | 1103.383333 | 0 | B | 3177.056381 | 39.37354854 | Planned Request Customer | PM | 1.7 |
15598585 | 4/1/13 0:21 | 4/1/13 1:10 | CMP | 2 | 49 | 98 | C | 36660.45295 | 3067.457455 | Failure Wear | PM | 1.7 |
15598586 | 4/1/13 1:51 | 4/1/13 5:06 | CMP | 0 | 195.3166667 | 0 | D | 2694.555091 | 2148.102147 | Outside Factor Fire | PM | 1.7 |
15598587 | 4/1/13 2:24 | 4/1/13 4:45 | CMP | 8 | 140.4666667 | 1123.73333 | D | 6912.50926 | 5185.59996 | Outside Factor Fire | PM | 1.7 |
15598588 | 4/1/13 4:21 | 4/1/13 5:50 | CMP | 2 | 88.26666667 | 176.533333 | E | 5885.557965 | 4763.835065 | Animal | PM | 1.7 |
15598589 | 4/1/13 6:19 | 4/1/13 6:53 | CMP | 1 | 33.86666667 | 33.8666667 | C | 39680.6477 | 36486.94172 | Unselected | PM | 1.7 |
15598590 | 4/1/13 7:18 | 4/1/13 9:15 | CMP | 1 | 116.6833333 | 116.683333 | F | 4205.015999 | 1036.788266 | Animal | PM | 1.7 |
15598591 | 4/1/13 7:20 | 4/1/13 7:36 | CNL | 1 | 15.85 | 15.85 | Warrensburg | 6204.30426 | 1094.586421 | Unknown | PM | 1.7 |
15598592 | 4/1/13 7:21 | 4/1/13 9:01 | CMP | 0 | 99.7 | 0 | C | 2313.85771 | 1892.462309 | Unselected | PM | 1.7 |
15598593 | 4/1/13 7:22 | 4/1/13 8:36 | CMP | 0 | 74 | 0 | C | 2284.255074 | 1519.403311 | Unselected | PM | 1.7 |
15598594 | 4/1/13 7:37 | 4/12/13 18:00 | CNL | 0 | 16463.08333 | 0 | A | 313.0291175 | 156.1489578 | Unknown | PM | 1.7 |
15598595 | 4/1/13 7:54 | 4/1/13 13:53 | CMP | 0 | 358.2833333 | 0 | G | 18594.87236 | 6179.357804 | PM | 1.7 | |
15598596 | 4/1/13 8:08 | 4/1/13 11:01 | CMP | 1 | 172.6166667 | 172.616667 | H | 19719.91549 | 18605.85861 | PM | 1.7 | |
15598597 | 4/1/13 8:10 | 4/1/13 12:53 | CMP | 0 | 282.65 | 0 | A | 44.9209252 | 29.55197266 | Unselected | PM | 1.7 |
15598598 | 4/1/13 8:13 | 4/2/13 12:45 | CMP | 0 | 1711.6 | 0 | A | 2765.036062 | 1001.251323 | Failure Wear | PM | 1.7 |
15598599 | 4/1/13 8:14 | 4/1/13 17:40 | CMP | 2 | 565.3 | 1130.6 | I | 2338.265835 | 834.2864042 | Planned Request | PM | 1.7 |
15598600 | 4/1/13 8:15 | 4/1/13 11:54 | CMP | 0 | 219 | 0 | C | 25071.04088 | 16298.84957 | Unselected | PM | 1.7 |
15598601 | 4/1/13 8:17 | 4/1/13 17:03 | CMP | 1 | 525.7666667 | 525.766667 | J | 2118.356997 | 414.0393082 | Planned Request | PM | 1.7 |
15598602 | 4/1/13 8:21 | 4/1/13 9:16 | CMP | 0 | 54.1 | 0 | K | 25165.46525 | 210.0593581 | Vegetation Trees | PM | 1.7 |
15598603 | 4/1/13 8:21 | 4/3/13 12:59 | CMP | 0 | 3157.6 | 0 | L | 7841.892158 | 1030.431465 | Unselected | PM | 1.7 |
15598604 | 4/1/13 8:30 | 4/1/13 11:13 | CMP | 1 | 162.2 | 162.2 | G | 22797.22658 | 10372.7451 | Failure Wear | PM | 1.7 |
OK turns out this was way easier than I was making it. Instead of messing with the formula and doing everything 'by force', there is a Quick Measure for Year to Date. I thought at the time I was playing with it that the YTD would only work for data in the current year, but it will actually work for multiple years. I was able to add a YTD version of the metric and it worked perfectly and gave me the exact graph I was looking for there.
Give it a shot
Metric Cumulative = CALCULATE ( SUM ( 'Raw Data'[Component] ) / [Average Customers], FILTER ( ALLSELECTED ( 'Raw Data' ), 'Raw Data'[Start Date] <= MAX ( 'Raw Data'[Start Date] ) && YEAR ( 'Raw Data'[Start Date] ) = YEAR ( SELECTEDVALUE ( 'Raw Data'[Start Date] ) ) ) )
Hm that didn't work, nothing is plotting at all. I tried adjusting the legend / axis settings but no dice. It's acting as if there are no records where that matches.
I tried setting it to <= and still nothing plotted, but when I set it to >= it plotted the same graph as before. It would need to be = but I don't know why it doesn't work.
Could you share your file?
Unfortunately no I can't, it has some sensitive data.
The format is something like this:
Customer Count Table:
Territory | Customers | Year | Month | YearMon |
A | 37,381.00 | 2017 | 12 | 201712 |
B | 47,416.00 | 2017 | 12 | 201712 |
C | 10,106.00 | 2017 | 12 | 201712 |
D | 109,685.00 | 2017 | 12 | 201712 |
E | 64,144.00 | 2017 | 12 | 201712 |
F | 9,551.00 | 2017 | 12 | 201712 |
G | 152,264.00 | 2017 | 12 | 201712 |
H | 61,934.00 | 2017 | 12 | 201712 |
I | 20,968.00 | 2017 | 12 | 201712 |
J | 10,536.00 | 2017 | 12 | 201712 |
K | 14,323.00 | 2017 | 12 | 201712 |
L | 7,801.00 | 2017 | 12 | 201712 |
M | 101,184.00 | 2017 | 12 | 201712 |
N | 30,221.00 | 2017 | 12 | 201712 |
O | 17,931.00 | 2017 | 12 | 201712 |
P | 15,918.00 | 2017 | 12 | 201712 |
Q | 83,562.00 | 2017 | 12 | 201712 |
R | 49,529.00 | 2017 | 12 | 201712 |
S | 2,844.00 | 2017 | 12 | 201712 |
T | 21,332.00 | 2017 | 12 | 201712 |
A | 37,452.00 | 2018 | 1 | 20181 |
B | 47,483.00 | 2018 | 1 | 20181 |
C | 10,108.00 | 2018 | 1 | 20181 |
D | 109,898.00 | 2018 | 1 | 20181 |
E | 64,600.00 | 2018 | 1 | 20181 |
F | 9,548.00 | 2018 | 1 | 20181 |
G | 152,249.00 | 2018 | 1 | 20181 |
H | 61,999.00 | 2018 | 1 | 20181 |
I | 20,983.00 | 2018 | 1 | 20181 |
J | 10,530.00 | 2018 | 1 | 20181 |
K | 14,327.00 | 2018 | 1 | 20181 |
L | 7,804.00 | 2018 | 1 | 20181 |
M | 105,975.00 | 2018 | 1 | 20181 |
N | 30,184.00 | 2018 | 1 | 20181 |
O | 18,001.00 | 2018 | 1 | 20181 |
P | 15,908.00 | 2018 | 1 | 20181 |
Q | 83,549.00 | 2018 | 1 | 20181 |
R | 49,557.00 | 2018 | 1 | 20181 |
S | 2,835.00 | 2018 | 1 | 20181 |
T | 21,348.00 | 2018 | 1 | 20181 |
A | 10,512.00 | 2018 | 3 | 20183 |
B | 14,583.00 | 2018 | 3 | 20183 |
C | 7,795.00 | 2018 | 3 | 20183 |
D | 105,777.00 | 2018 | 3 | 20183 |
E | 30,154.00 | 2018 | 3 | 20183 |
F | 18,058.00 | 2018 | 3 | 20183 |
G | 15,895.00 | 2018 | 3 | 20183 |
H | 83,514.00 | 2018 | 3 | 20183 |
I | 49,475.00 | 2018 | 3 | 20183 |
J | 2,826.00 | 2018 | 3 | 20183 |
K | 21,353.00 | 2018 | 3 | 20183 |
L | 37,498.00 | 2018 | 3 | 20183 |
M | 47,551.00 | 2018 | 3 | 20183 |
N | 10,104.00 | 2018 | 3 | 20183 |
O | 109,784.00 | 2018 | 3 | 20183 |
P | 64,638.00 | 2018 | 3 | 20183 |
Q | 9,586.00 | 2018 | 3 | 20183 |
R | 152,341.00 | 2018 | 3 | 20183 |
S | 62,076.00 | 2018 | 3 | 20183 |
T | 21,019.00 | 2018 | 3 | 20183 |
Event Table:
Event Table
Event | Metric Component | Date/Time | Year-Mon |
1 | 10 | 1/1/2018 5:30AM | 2018-1 |
2 | 42 | 1/3/2018 5:30AM | 2018-1 |
3 | 5431 | 2/1/2018 5:30AM | 2018-2 |
4 | 249 | 2/1/2018 6:30AM | 2018-2 |
My Average Customer formula is:
Average Customers Served = AVERAGEX( summarize('Customers by Center', 'Customers by Center'[Year], 'Customers by Center'[Month], "CustomSum", SUM('Customers by Center'[Customers]) ), [CustomSum] )
The Metric (non cumulative version) is:
Metric = sum('Raw Data'[Component])/[Average Customers Served]
And that works great, except that I'm wanting a graph that will show the month to month accumulation by year, and then I want to be able to drill into that line graph to see the day to day accumulation by month. I just can't get the Cumulative component to split based on year. The SelectedValue, do you think it's returning more than one element? Is that why it isn't returning anything at all when I specify <= or = year in the formula you provided? I think that methodology should work, but I'm not very familiar with how SelectedValue() works
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 |
---|---|
107 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |