Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Substract first month value from rest all months

 

Hello Friends,

 

I am struggle to get logic. Month & Sales

JanFebMarAprMayJunJulAugSepDec
212535456569708087100

My requirement is

 

A= 21(Jan)

B=100(Dec)

([Sales]-A)/(B-A)

The result should be

JanFebMarAprMayJunJulAugSepDec
0(25-21)/(100-21)=0.****(35-21)/(100-21)=0.****456569708087100

Kindly help me on solution

  • Anonymous  if you have a table like this

     

    monthvalue
    jan21
    feb25
    march35
    apr45
    may65
    june69
    july70
    aug80
    sep87
    oct90
    nov92
    dec100

     

    and the final fraction to follow the following logic

    A= 21(Jan)

    B=100(Dec)

    ([Sales]-A)/(B-A)

     

    You can reach what you need by using following measures

     

    Sales:= SUMX(X,X[value])
    
    only jan sales (A) := CALCULATE([Sales],ALL(X),X[month]="jan")
    
    only dec sales (B):= CALCULATE([Sales],ALL(X),X[month]="dec")
    
    Numerator (Sales-A):= [Sales]-[only jan sales (A)]
    
    Denominator (B-A):= [only dec sales (B)]-[only jan sales (A)]
    
    Fraction:= [Numerator (Sales-A)]/[Denominator (B-A)]

     

     

4 Replies

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    Anonymous  if you have a table like this

     

    monthvalue
    jan21
    feb25
    march35
    apr45
    may65
    june69
    july70
    aug80
    sep87
    oct90
    nov92
    dec100

     

    and the final fraction to follow the following logic

    A= 21(Jan)

    B=100(Dec)

    ([Sales]-A)/(B-A)

     

    You can reach what you need by using following measures

     

    Sales:= SUMX(X,X[value])
    
    only jan sales (A) := CALCULATE([Sales],ALL(X),X[month]="jan")
    
    only dec sales (B):= CALCULATE([Sales],ALL(X),X[month]="dec")
    
    Numerator (Sales-A):= [Sales]-[only jan sales (A)]
    
    Denominator (B-A):= [only dec sales (B)]-[only jan sales (A)]
    
    Fraction:= [Numerator (Sales-A)]/[Denominator (B-A)]

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Super,

      Works for me.

      Thank you for your quick help and support.

       

      Regards,

       

      Babu

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    IF your data is really organized in the way it is shown (it seems unlikely), so a column for Jan, another column for Feb and so on, 

    Then you can just add columns to your table with the calculation as you described.

     

    For instance for FEB : Calc Feb = Divide((sum(Data[Feb]) - Sum(Data[Jan])),sum(data[dec])-sum(Data[Jan]))
     
     
    Otherwise it is better to show how your data is organized, and also why Sep and Oct are missing.
     
    Jan 
    • Anonymous's avatar
      Anonymous
      Not applicable

      Dear JustJan,

       

      Sorry for not elobarate requirement to you, but smpa01 solution working for me.

       

      thank you for your quick response.

       

      Regards,

       

      Babu