Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
timknox
Helper II
Helper II

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

1 ACCEPTED SOLUTION

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] ) )

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

7 REPLIES 7
LivioLanzo
Solution Sage
Solution Sage

Hi @timknox

 

this is possible to do with some Power Query steps in order to prepare the data.

 

I have uploaded the PBIX here: https://1drv.ms/u/s!AiiWkkwHZChHjzpzpaIDO9ValBiQ

 

Let me know if something not clear.

 

Capture.PNG

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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

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' ?

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Yes - so it is pulling the two together into one Matrix

Hi @timknox

 

the quickest solution that comes to mind is to split the table I have created into two tables where one table would have the Cost and Original Date as Columns and the other table would have the Profit and 'RealDate' ( the date column I added ) as columns. 

These two tables would both be related to the calendar table. Then you would just need to create a measure that does

 

= SUM( CostTable[TotalCost] ) + SUM( ProfitTable[Profit] )

 

let me know if this works for you

 

 

 

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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] ) )

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Bingo - very many thanks for your help

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors