Forum Discussion

JLMLV00's avatar
JLMLV00
Frequent Visitor
3 years ago

Measure instead of calculated columns

Hi, 
I want to calculate de difference between invoiced amount (€) and a recalculated amount. I get it done with calculated columns in my FactInvoices table but instead i would rather use a measure if this is possible.  
I want for each invoice row the difference between invoiced and recalculated amount using these tables.  
Some of the clients get at the end of a period a recalculated price, this price is based on another pricelist in pricingsmethod table with conditions such as product ID, between start and end date and invoiced units. 
can i get this done without using calculated columns? 
In table invoices is an example of the invoices the columheaders with red text colour is expected output (and not a part of original table)

RecalculationTable            
Client id Start dateEnd dateProduct IDStarting amount (units)Ending amount (units)discount Listprice     
A1-1-202231-12-20231001000001,53     
B1-1-202231-12-202315035000,52     
B1-1-202231-12-20231535001000012     
             
             
PricingTable            
Date

Product ID

Pricingmethod1Pricingmethod2Pricingmethod3        
10-5-2023

15

2,833,2        
23-3-2023152,52,852,65        
             
InvoiceTable            
DateinvoicenumerClient product idTotal amount unitsPriceTotal €Pricingmetod invoicedRecalculation methodPrice recalculatedRecalculated discountRecalculated total €Difference
23-3-2023100A105002,5                            1.250,00132,651,5         575,00       -675,00
10-5-2023102B1510002,8                            2.800,001230,5     2.500,00       -300,00
23-3-2023101B1536002,5                            9.000,00122,851     6.660,00   -2.340,00
10-5-2023103A256002,8                            1.680,001None-   

2 Replies

    • JLMLV00's avatar
      JLMLV00
      Frequent Visitor

      Thanks a lot, 
      hope you can help me out with this one, 
      Client A has more than one rows in the recalculationtable 
      from 1-1-23 till 30-6-23 their recalculated pricing method is 2 
      from 1-7-23 till 31-12-23 pricing method is 3 
      with Sumx <=max(date) etc.  the invoicerows from 1-1-23 till 30-6-23 wont show their recalculation pricing, because he's gonna use the max dates of the clients, when used MIN() the invoice rows after 30-6-23 wont show up. 
      SUMX(Filter(Invoicetable,Invoicetable[date]>=Max(Recalculationtable[startdate]&&Invoicetable[date]<=Max(Recalculationtable[Enddate]), [Listprice])