Forum Discussion

jaymetbar's avatar
jaymetbar
Frequent Visitor
6 years ago

Need help creating calculated column using data from different table between 2 dates

Hello Again,

 

I have a table titled "Daily Amperage Data" and I have a table titled "Current Efficiency". I would like to add a new column within "Current Efficiency" which will generate an average amperage for the time between when a cell is harvested. I would also like to add another column which would have the value of the number of days that have elapsed since that cell was harvested.

 

Here are my Tables:

Daily Amperage Data

Production DateNorth AmpsWest Amps
Friday, January 1, 20102360521511
Saturday, January 2, 20102339720766
Sunday, January 3, 20102086224511
Monday, January 4, 20102486423175
Tuesday, January 5, 20102253320375
Wednesday, January 6, 20102355223112
Thursday, January 7, 20102029920081
Friday, January 8, 20102234520276
Saturday, January 9, 20102366923203
Sunday, January 10, 20102464722383
Monday, January 11, 20102040521362
Tuesday, January 12, 20102294521624
Wednesday, January 13, 20102044322062
Thursday, January 14, 20102443924136
Friday, January 15, 20102038221179
Saturday, January 16, 20102045622797
Sunday, January 17, 20102003224161

 

Current Efficiency 

Production DateCell NumberProductionTrue Production
Friday, January 1, 20101501251312713
Friday, January 1, 20101601014810348
Friday, January 1, 20101701078810988
Friday, January 1, 20102501015510355
Friday, January 1, 20102601280413004
Friday, January 1, 20102701124211442
Saturday, January 2, 20101801161411814
Saturday, January 2, 20101901058610786
Saturday, January 2, 20101001239912599
Saturday, January 2, 20102801220012400
Saturday, January 2, 20102901137511575
Saturday, January 2, 20102001079910999
Sunday, January 3, 20101101141311613
Sunday, January 3, 20101201236712567
Sunday, January 3, 20101301110911309
Sunday, January 3, 20102101181012010
Sunday, January 3, 20102201194112141
Sunday, January 3, 20102301169011890
Monday, January 4, 20101401188012080
Monday, January 4, 20101501220112401
Monday, January 4, 20101601242412624
Monday, January 4, 20101701034210542
Monday, January 4, 20102501159711797
Monday, January 4, 20102601181212012
Tuesday, January 5, 20102701142911629
Tuesday, January 5, 20101801186112061
Tuesday, January 5, 20101901187112071
Tuesday, January 5, 20101001242212622
Tuesday, January 5, 20102801037610576
Tuesday, January 5, 20102901272812928
Wednesday, January 6, 20102001288113081
Wednesday, January 6, 20101101042110621
Wednesday, January 6, 20101201081311013
Wednesday, January 6, 20101301188612086
Wednesday, January 6, 20102101132411524
Wednesday, January 6, 20102201167011870
Thursday, January 7, 20102301165211852
Thursday, January 7, 20101401110711307
Thursday, January 7, 20101501174511945
Thursday, January 7, 20102301076110961
Thursday, January 7, 20102401051410714
Thursday, January 7, 20102501006810268
Friday, January 8, 20101601122511425
Friday, January 8, 20101701027610476
Friday, January 8, 20101801088511085
Friday, January 8, 20102601172611926
Friday, January 8, 20102701241712617
Friday, January 8, 20102801196912169

 

So I'd like to create a new column which shows the average Amperage for cell 150 over its cycle. So initially it is harvested on January 1st. And it is harvested again on January 5th. I would like the column to be the average of amps between January 1st and January 5th. The second column should be something along the lines of Days between when that cell was harvested. 

 

Cells fed by the North Amperage are the "100" cells. 110, 120, 130 etc.

Cells fed by the West Amperage are the "200" cells. 210, 220, 230 etc.

 

Please let me know if you need further clarification. I understand I'll have null data in the first few days until the cycle repeats itself.

 

Thank You for your help!

7 Replies

    • jaymetbar's avatar
      jaymetbar
      Frequent Visitor

      Hi Greg,

       

      Sorry about that. I corrected the data to include more cells. Anything in the 100 series would be a North Amperage fed cell and anything in a 200 series would be a West Amperage fed cell.

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    jaymetbar 

    Did you missed out a column somewhere that should show us NorthAmps/West Amps for each cell?

     

    Regards

    Paul

    • jaymetbar's avatar
      jaymetbar
      Frequent Visitor

      Hi Paul,

       

      Sorry, i got a little hasty when making my dummy data and left out some key info. Cells that are 100-190 are fed by North Amps and cells that are 200-290 are West Amps.

      • Anonymous's avatar
        Anonymous
        Not applicable

        jaymetbar 

        1. I assumed you related the two tables with Dates, you can move the Amps to the Current Efficiency table using, I used SWTICH instead of IF because there are may be 300, 400... cells.

         

        Amps = SWITCH(TRUE(),
        [Cell Number]>=100 && [Cell Number]<=190,RELATED('Daily Amperage Data'[North Amps]),
        [Cell Number]>=200 && [Cell Number]<=290,RELATED('Daily Amperage Data'[West Amps]))

         

         2. Create the two expected columns with: 

         

        Column 1 = 
        CALCULATE(AVERAGE('Current Efficiency'[Amps]),FILTER('Current Efficiency',[Cell Number]=EARLIER([Cell Number])&&[Production Date]<=EARLIER([Production Date])))
        
        Column 2 = 
        var nextdate = CALCULATE(MAX([Production Date]),FILTER('Current Efficiency',[Cell Number]=EARLIER([Cell Number])&&[Production Date]<EARLIER([Production Date])))
        Return DATEDIFF(nextdate,[Production Date],DAY)

         

         

        Pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/paul_qiuyunus_onmicrosoft_com/ERRN_hTYt3FNoMlzT7tmj2QBxFxH5DmebvYe5v9P8hrpIA?e=ip6cXD

         

        Paul Zheng _ Community Support Team
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.