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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JLMLV00
Frequent Visitor

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 2
amitchandak
Super User
Super User

@JLMLV00 , You have force that calculation at row level in meausre

 

Example

Sumx(Table,

var _col = <Column calc>

return <More calc> )

 

or

Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.