Forum Discussion

kalpanaV's avatar
kalpanaV
Helper IV
9 years ago

Do calculation on cell level

Hi

Here, i want to display in the new column  for the first row (2/45)1*12

second row =( (2+3)/24)2*12

third row =((3+2+1)/30)/3*12

how to write dax.

11 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi kalpanaV,

     

    You should use a iterator function like SUMX to do row based calculations. 

    The formula might need a little change because only in the third row i see you divide the result by 3*12 and because there is no desired result please check if the formule is fully correct.

     

    First define a measure that counts the V column as a running total, I called it YTD but actually it uses the Index now. Consider using a date column so you could use an actual YTD function. Below the V_YTD and calculation like described.

     

    V_YTD = 
    VAR CurrentIndex = MAX('Table'[Index])
    RETURN
    CALCULATE( SUM('Table'[v]);
    	FILTER(
    		ALLSELECTED('Table');
    		'Table'[Index] <= CurrentIndex
    	))
    
    NewCalc = 
    VAR V = SUM('Table'[v])
    VAR HC = SUM('Table'[HC])
    VAR V_YTD = [V_YTD]
    RETURN
    SUMX(
    	'Table';
    	(V_YTD/HC)/'Table'[Index] * 12)

    Result:

     

  • Hi kalpanaV,

     

    Your fomular is not clear. but you could create calculated column:

    % attr = 
    var currentIndex= Data[Index]
    var currentHC= Data[HC]
    var total = CALCULATE(SUM(Data[V]),FILTER(Data,Data[Index]<=currentIndex))
    return 12* DIVIDE(total,Data[HC]*currentIndex)

     

     

    • kalpanaV's avatar
      kalpanaV
      Helper IV

      hi 

      Thanks 

       

      but the thing is,  i have to take HC from other table which is having four months of data.

      V column is the one which i have to take count having only V from another column in the same table.

       

      hope, i explained clear now

      • tringuyenminh92's avatar
        tringuyenminh92
        Memorable Member

        Hi kalpanaV,

         

        I got your situation cause i'm used to work with HR data, for beginner, the simple way is you use "group by" (Summarize method or Addcolumns with Summarize method) to generate new table like your picture. Or you could let me observe your sample transaction data to have proper solution(cause i'm not sure that could achieve your requirement with one measure expression)