Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

not enough memory for a specific column?

Hey, 

 

I am having some trouble with an equation, I have a column of data for TotalEnergy, and this column accumulates all the energy in total for different devices, and I wanna make a column for that takes current value minus previous for a specific device, I had a function that worked well: 

 

NewEnergyPer300s_kWh =
VAR minIndx = CALCULATE (
MAX ( Data[Index] ),
ALLEXCEPT ( Data, Data[Device] ),
Data[Index] < EARLIER (Data[Index] )
)
 
RETURN
 
IF (
ISBLANK ( minIndx ),
BLANK (),
Data[TotalEnergy_kWh]
    - CALCULATE (
               SUM ( Data[TotalEnergy_kWh] ),
                   Data[Index] = minIndx,
                       ALL ( Data )
)
)

 

 

It does eaxctly what I want it to do, BUT Iam getting an error saying there is not enough memory capacity, it works fine when I filter it down to one device for example, but not with several. (There is only 71.000 rows of data aswell!) Is it possible to write this as a measure maybe? Or is there any other way I can write it?

 

Also I have started to try this equation, but I don't know where to add so it it just for the specific device, this equation only takes current value minus previous row undependent on what device it is: 

 

NewEnergyPer300s2_kWh =
Var BaseValue = Data[TotalEnergy_kWh]
Var BaseDate = Data[EndUtc]
Var DateCheck = LOOKUPVALUE(Data[EndUtc], Data[Index], Data[Index]-1)
Var ValueToSubtract = IF('Data'[Index]=0, Data[TotalEnergy_kWh], LOOKUPVALUE(Data[TotalEnergy_kWh], Data[Index], Data[Index]-1))
RETURN
IF(FORMAT(BaseDate, "YYYY-MM-DD HH:mm")= FORMAT(DateCheck, "YYYY-MM-DD HH:mm"), IF(ISBLANK(ValueToSubtract), BaseValue-BaseValue, BaseValue-ValueToSubtract),BaseValue-BaseValue)
 
 
Any tips or ideas on how I can change it?
 
Kind regards Agnes
 
 
 

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, 

       

      thanks, but I don´t understand why a ranked column would be better then the index, where would I even put in the formula? Also do you know why the first one wont work?

       

      Kind regards 

      • v-cherch-msft's avatar
        v-cherch-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi Anonymous

         

        It seems an issue with memory. Here is the article for your reference. You may try to optimize your model and formula.  If you could share the file, it would be better for us to help further on it.

         

        Regards,

        Cherie

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks!

       

      I am doing the rankx formula, but I can't use the formula in to calculate the energy, I just get the answer I can't use it as a multiple scalar, (It gets many ranking number that will be the same, as for I have five different products, I willl get 5 different Rank 1), Is it possible to use the RankX for this question then? 

       

      I want a formula that take the value minus the value of previous index for that product. 

       

      Kind regards

  • Anonymous's avatar
    Anonymous
    Not applicable
    I have tried this formula as well, and I am trying to change Index to Rank, but I am not getting correct values. 
     
    NewEnergyPerDay_kWh =
    var maxIndex =CALCULATE( MAX('Data'[Index]), FILTER('Data','Data'[Index]=EARLIER('Data'[Index])), ALLEXCEPT(Data,Data[Device]))
    VAR minVal='Data'[TotalEnergy_kWh]
    var maxVal= IF('Data'[Index]=maxIndex,
    LOOKUPVALUE('Data'[TotalEnergy_kWh],'Data'[Index],'Data'[Index]),
    LOOKUPVALUE('Data'[TotalEnergy_kWh],'Data'[Index],'Data'[Index]+1))
    RETURN
    CALCULATE(DIVIDE(minVal-maxVal,1,0),FILTER('Data','Data'[Index]=EARLIER('Data'[Index])), ALLEXCEPT(Data,Data[Device]))