Forum Discussion

Kolumam's avatar
Kolumam
Icon for Post Prodigy rankPost Prodigy
6 years ago

Need urgent help - DAX calculation

I have the below table.

 

Start Date of ContractEnd Date of ContractOperation NameComprehensive O&M Price
1/7/201931/8/2019X375
1/9/201931/3/2020X405
12/5/202031/12/2021X385
1/4/201731/3/2018Y380
1/4/201831/3/2020Y410
11/5/202031/12/2021Y303

 

Based on the start date of contract and end date of contract for each Operation Name, I need to calculate the annual contract for each operation name.

 

Expected Output with Calculation: 

 

Operation NameYearAnnual ContractCalculation
X2019395(375*60/180)+(405*120/180)
X2020353.01(405*90/365)+(385*240/365)
X2021385(385*365/365)
Y2017380(380*365/365)
Y2018396.97(380*90/365)+(410*270/365)
Y2019410(410*365/365)
Y2020300.23(410*90/365)*(303*240/365)
Y2021303303*365/365

 

Thanks in advance for the help.

@amitchandak @parry2k @mahoney19 @Amit @amitchandak @parry2k @az38 @jdbuchanan71 @mahoneypat @edhans @harshnathani @v-kellya-msft @MFelix @Ashish_Mathur @BA_Pete @ryan_mayu @kbuckvol @Alexander76877 @Petazo @Mariusz @TomMartens @Greg_Deckler @tjd @Sean @mikstra @AllisonKennedy @EricHulshof @briandpeterson @USG_Phil @vpatel55 @mwegener @v-piga-msft @tex628 @sturlaws @Vvelarde @CheenuSing @MarcelBeug @Zubair_Muhammad @v-piga-msft @danextian @MattAL @MattAllington @roalexan @Alexander76877 @kgc 

6 Replies

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

    Kolumam - Can you explain the logic behind the calculations that you have presented?

     

    So, for example, 

     

    (375*60/180)+(405*120/180)

     

    So, I get where the 375 and 405 come from. Is the 60 and 120 the number of months within 2019 for which the contract is valid and you are assuming 30 day months? Where does the 180 come from? I would think 60 + 120 but then the next line is:

     

    (405*90/365)+(385*240/365)

     

    And 90 and 240 do not add up to 365. 

     

    Then you have the 2021 stuff where suddenly you switch to 365/365 (which is 1) soooooo.... Puzzled.

     

    All of that said, you are going to probably end up needing to use something like GENERATE since if you solve this in DAX because you need to essentially "invent" rows in a table and there are limited options for doing things like that.

     

    • Kolumam's avatar
      Kolumam
      Icon for Post Prodigy rankPost Prodigy

      Hi Greg_Deckler 

       

      Please find my explanation for the calculation.

       

      (375*60/180)+(405*120/180)

       

      Here 60 is the number of days for which the contract is valid (end date - start date) and 180 is the total number of days between 1 July 2019 and 31st December 2019. I am using the days approximately but ideally it should be the exact number of days.

       

      For this one: (405*90/365)+(385*240/365)

       

      90 because the contract is from 1st Jan 2020 to 31 March 2020 and 240 is because the the start date is 12/5/2020 and ends at 31st Dec 2020. I am taking rough numbers. Not the exact difference in days.

       

      For the last contract, the contract applies for whole year. Hence 385*365/365