Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Nandor
Helper I
Helper I

Accumulate the values to get an increasing line chart

Hi,

 

I have a database in which we log at around every 15 minutes the number of tablets produced. I have a date and a qunatity.

 

We would need to see a line chart that accumulates the values, generating an increasing line.

 

For Example:

 

At 6.30 we start from 0

At 6.45 we produced 10.000 tablets

At 7.05 we produced another 12.000 tablets

At 7.30 we produced another 16.000 tablets.

 

My data looks like this

Date&Time    Qunatity

6.30                   0

6.45                 10.000

7.05                 12.000

7.30                 16.000

 

On the line chart I would like to se ponits at the following values:

At 6.30 : 0

At 6.45 : 10.000

At 7.05 : 22.000 (10.000+12.000)

At 7.30 : 38.000 (10.000+12.000+16.000)

 

Thank you,

Nandor

 

1 ACCEPTED SOLUTION
KGrice
Memorable Member
Memorable Member

Hi @Nandor. See if the picture below is what you had in mind. I'm not sure what you want to do when you start another day, so I set it to reset to 0 each new day with some made up data.

 

TabletsProduced.PNG

 

I noticed the heading of your column is Date&Time, but I only saw time values in the sample. I'm assuming you either have a date as well, or maybe it's in another column. Here's what I ended up with:

 

TabletData.PNG

 

Starting with a DateTime column and Quantity column, I added the separate Date and Time columns in the Query Editor. To do that, select the DateTime column, then go to the Add Column tab in the ribbon, click the Date drop-down, and select Date Only. For the Time column, you'll do the same, except you'll click the Time drop-down and select Time Only.

 

After you Close and Apply to load your data, create two new measures (Modeling tab in the ribbon > New Measure).

 

Tablets Produced = SUM(TableName[Quantity])

 

Daily Tablets Produced = CALCULATE(
[Tablets Produced],
FILTER(ALL(TableName), TableName[Date]=MIN(TableName[Date])
&& TableName[Time]<=MAX(TableName[Time]))
)

 

The measure names are up to you. For the chart, drag the DateTime column onto the report canvas. Change the visual to a Line chart in the Visualizations pane, and then under Axis you'll probably need to click the DateTime field drop-down and select DateTime instead of the defaulted Date Hierarchy. Then drag the Daily Tablets Produced measure into the Values section of the chart.

 

To get the line chart to show every measurement time, click the Format section while the chart is selected, and click the drop-down under X-Axis to see the options there. Chagne the type from Continuous to Categorical.

 

If you also wanted a visualization of how many were produced each hour, you could then change the chart to a Line and Clustered Column chart. Drag Daily Tablets Produced to the Line Values and add Tablets Produced to the Column Values. It would end up like this:

 

ComboChart.PNG

 

 

View solution in original post

3 REPLIES 3
KGrice
Memorable Member
Memorable Member

Hi @Nandor. See if the picture below is what you had in mind. I'm not sure what you want to do when you start another day, so I set it to reset to 0 each new day with some made up data.

 

TabletsProduced.PNG

 

I noticed the heading of your column is Date&Time, but I only saw time values in the sample. I'm assuming you either have a date as well, or maybe it's in another column. Here's what I ended up with:

 

TabletData.PNG

 

Starting with a DateTime column and Quantity column, I added the separate Date and Time columns in the Query Editor. To do that, select the DateTime column, then go to the Add Column tab in the ribbon, click the Date drop-down, and select Date Only. For the Time column, you'll do the same, except you'll click the Time drop-down and select Time Only.

 

After you Close and Apply to load your data, create two new measures (Modeling tab in the ribbon > New Measure).

 

Tablets Produced = SUM(TableName[Quantity])

 

Daily Tablets Produced = CALCULATE(
[Tablets Produced],
FILTER(ALL(TableName), TableName[Date]=MIN(TableName[Date])
&& TableName[Time]<=MAX(TableName[Time]))
)

 

The measure names are up to you. For the chart, drag the DateTime column onto the report canvas. Change the visual to a Line chart in the Visualizations pane, and then under Axis you'll probably need to click the DateTime field drop-down and select DateTime instead of the defaulted Date Hierarchy. Then drag the Daily Tablets Produced measure into the Values section of the chart.

 

To get the line chart to show every measurement time, click the Format section while the chart is selected, and click the drop-down under X-Axis to see the options there. Chagne the type from Continuous to Categorical.

 

If you also wanted a visualization of how many were produced each hour, you could then change the chart to a Line and Clustered Column chart. Drag Daily Tablets Produced to the Line Values and add Tablets Produced to the Column Values. It would end up like this:

 

ComboChart.PNG

 

 

Hi, thank you for the solution, you were lightning fast.

 

Thank you again,

Nandor

 

 

Hi, I need your help again, I can't figure it out why my data difer form the original values.

 

I exported the following table from Power BI, and column 2 and 3 should be almoust equal, differences should be only a few tablets, as seen on the last column.

 

The calculation of the number of tablets between two calculations is correct (as can be seen in rows 4,5 and 6, I used the following excel formula to calculate the values: =IF(B4-B3>0,B4-B3,0)), exept that it misses one value when we restart from zero, because a new batch was started. Could you help me to finetune the formula you gave in the solution to eliminate the problems at the start of the batches?

 

At the beginnig of each batch it is normal to have two identical number of tablets, because the equipment is started for a short time than it waits for thein process controll. When restarted the same value is introduced again.

 

Measurement_Date&TimeMeasurement_QuantityTabletsProduced_DailyTablets produced (calculated in excel)TabletsProducedDifference between excel and DEX
05/09/2016 06:290000Differences come from my calculation, the only value that we ned to look into is 4262 in line 33
05/09/2016 09:000959300 
05/09/2016 09:014420959344200 
05/09/2016 09:3144201408000 
05/09/2016 09:47234903472519070190655
05/09/2016 10:064339958818199091989316
05/09/2016 10:20580907350414691146865
05/09/2016 10:377649594145184051839411
05/09/2016 10:5291390111835148951488213
05/09/2016 11:08108857133607174671745611
05/09/2016 11:2512677515342517918179180
05/09/2016 11:4114361017025716835168323
05/09/2016 11:5315599918498912389123863
05/09/2016 12:0616887519936512876128760
05/09/2016 12:2318752522041418650186491
05/09/2016 12:4220652024193418995189905
05/09/2016 12:5522098525639014465144569
05/09/2016 13:12238215277891172301721614
05/09/2016 13:28255525297995173101729614
05/09/2016 13:4227031531277914790147846
05/09/2016 14:0529432534122024010240028
05/09/2016 14:2131043535974516110161100
05/09/2016 14:37327425376721169901697614
05/09/2016 14:5034150039298314075140669
05/09/2016 15:07358600412571171001708812
05/09/2016 15:2637920043316720600205964
05/09/2016 15:4039208544605012885128832
05/09/2016 15:5540890046286516815168150
05/09/2016 16:0942430048025315400154000
05/09/2016 16:41446771502697224712244427
05/09/2016 17:520505236000
05/09/2016 18:000506614000
05/09/2016 18:004262506614426204262
05/09/2016 18:264262506614000
05/09/2016 18:321878052112914518145153
05/09/2016 18:493621054061317430174246
05/09/2016 19:075526055965719050190446
05/09/2016 19:2270600579099153401533010
05/09/2016 19:3787110595599165101650010
05/09/2016 20:0211260062318725490254882
05/09/2016 20:1812960064371317000169928
05/09/2016 20:3514720066131317600176000
05/09/2016 20:50163802683135166021659012
05/09/2016 21:09183200705296193981938612
05/09/2016 21:2419870072099215500154982
05/09/2016 21:4822035174452221651216438
Total/day667122744522   

 Thank you,

Nandor

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.