Forum Discussion

timknox's avatar
timknox
Icon for Helper II rankHelper II
7 years ago
Solved

Help with a calculated measure please

I will try and explain what i am rying to achieve!

 

I have a flat data file, about 25 columns x 800,000 rows.  I have reproduced a subset for the purpose of this question:

 

CodeContract ItemCostTotal ProfitDate
BAB1.125.001.6301/09/2018
BAB1.135.002.2801/09/2018
BAC1.124.001.5601/09/2018
BAD1.228.001.8301/09/2018
BAE1.336.002.3501/10/2018
BAB1.129.001.8901/10/2018
BAE1.327.001.7601/10/2018
BDD4.558.003.7801/09/2018
BDF4.124.001.5601/09/2018
BAB1.122.001.4301/10/2018

 

Basically i am trying to manipulate the 'Total Profit', basically for when it was actually paid.  The column 'Date' is when it should be paid, but in some circumstances they are not.

 

I have a related table ('Date' <> 'Date') which states whether the 'Total Profit' was paid:

 

Date1.11.21.34.14.5
01/09/201801000
01/10/201811000
01/11/201811111
01/12/201811111
01/01/201911111

 

A zero means it was not paid on that month, and a 1 that it was. So for the 'Total Profits' for Contract 1.1 that should have been paid on 01/09/2018 were not; the 'Total Profits' for Contract 1.2 that should have been paid on 01/09/2018 were.

 

I have another similarly related table  that states when it was finally paid, if there is a zero in the table above:

 

Date1.11.21.34.14.5
01/09/201801/10/2018 01/10/201801/10/201801/10/2018
01/10/2018  01/11/201801/11/201801/11/2018
01/11/2018     
01/12/2018     
01/01/2019     

 

So the 'Total Profits' for Contract 1.1 that should have been paid on 01/09/2018, were actually paid on 01/10/2018.

 

One should then end up with values like this:

 

Date1.11.21.34.14.5
01/09/20180.001.830.000.000.00
01/10/20188.800.000.001.563.78
01/11/20180.000.004.110.000.00
01/12/20180.000.000.000.000.00
01/01/20190.000.000.000.000.00

 

And the Matrix i want to display in my report would look like this:

 

 01/09/201801/10/201901/11/202001/12/202101/01/2023
BAB 7.24   
BAC 1.56   
BAD1.83    
BAE  4.11  
BDD 3.78   
BDF 1.56   

 

Can anyone help me please?

 

Many thanks

 

Tim

  • LivioLanzo's avatar
    LivioLanzo
    7 years ago

    Another solution is to create an active relationship between the Calendar table and the 'Date' column and an inactive relationship between the Calendar Table and the 'RealDate' column I have added

     

    then you can try something like this:

     

    = SUM( Data[Cost] ) + CALCULATE( SUM(Data[Profit] ), USERELATIONSHIP( Data[RealDate], 'Calendar'[Date] ) )

7 Replies

    • timknox's avatar
      timknox
      Icon for Helper II rankHelper II

      LivioLanzo,

      That is great - many thanks...... can you help me with one more step please!

       

      I can produce a Matrix to show the 'Cost' against 'Date':

       

       01/09/201801/10/201901/11/202001/12/202101/01/2023
      BAB60.0051.00   
      BAC24.00    
      BAD28.00    
      BAE 63.00   
      BDD58.00    
      BDF24.00    

       

      I now have the Matrix you developed for me (thank you) for when the 'Total Profit' was paid:

       

       01/09/201801/10/201901/11/202001/12/202101/01/2023
      BAB 7.24   
      BAC 1.56   
      BAD1.83    
      BAE  4.11  
      BDD 3.78   
      BDF 1.56   

       

      Challenge!!!  How do i get the 2 together to give me this:

       

       01/09/201801/10/201901/11/202001/12/202101/01/2023
      BAB60.0058.24   
      BAC24.001.56   
      BAD29.83    
      BAE 63.004.11  
      BDD58.003.78   
      BDF24.001.56   

       

      Welcome your help again 

       

      Many thanks

      • LivioLanzo's avatar
        LivioLanzo
        Icon for Solution Sage rankSolution Sage

        Hi timknox,

         

        thank you for the feedback.

         

        Do you mean you want to show the cost by the 'Original Date' and the profit by the date I added: 'RealDate' ?