The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have 2 calculated columns for sales in local currency and sales in USD, the code are the same but the first works fine the second gives me Circular reference error, can anyone help me with this?
Step 1 created the share for a column named "share", which is done using the following code:
```
share =
VAR currentid = 'Table1'[ID]
VAR maxrevenue = MAXX(FILTER('Table1', 'Table1'[ID]=currentid), ABS('Table1'[Amount (Local currency)]))
VAR share = 'Table1'[Amount (Local currency)] / maxrevenue *
RETURN share *
```
Step2-fetch sales from table 2
I also have two other columns called "Sales USD" and "Sales Local Currency", which are calculated using the following code:
```
Sales USD = LOOKUPVALUE('Table2 list'[ Sales (USD)], 'Table2 list'[ID], 'Table1'[ID])
Sales Local Currency = LOOKUPVALUE('Table2 list'[ Sales__Local_currency], 'Table2 list'[ID], 'Table1'[ID])
```
Now, I want to multiply "Sales USD" with "share" for each row. So, I tried the following code:
```
Step 3- the error step
Sales Split = CALCULATE(SUMX('Table1', 'Table1'[Sales_Local_currency] * 'Table1'[share]))
```
This gives me the correct result. However, when I tried to do the same for "Sales USD", I got a circular reference error. Can you tell me why?
```
Sales Split USD = CALCULATE(SUMX('Table1', 'Table1'[Sales USD] * 'Table1'[share]))
```
Use a proper data model for this, rather than LOOKUPVALUE. Alternatively push the calculations upstream into Power Query.