Forum Discussion
hoopaz68
1 year agoNew Member
Dax Help
Good Afternoon. I'm fairly new to using DAX so bear with me. I'm trying to use DAX to calculate invoice amounts in different currencies. I have two example tables below in my PBI desktop. These...
- Anonymous1 year ago
Hi hoopaz68 ,
In the data you provided, the cruno field does not have a unique identifier and cannot be used as a condition for joining tables.
But based on your requirement, you can refer to the following formula:SelectedCurrencyRate = CALCULATE ( MAX ( 'Currency_Table'[rate] ), FILTER ( 'Currency_Table', 'Currency_Table'[cruno] = SELECTEDVALUE ( 'Invoice Table'[cruno] ) && 'Currency_Table'[currency] = SELECTEDVALUE ( 'Currency_Table'[currency] ) ) )ConvertedInvoiceAmount = SUMX( 'Invoice Table', 'Invoice Table'[inv_amt_usd] * [SelectedCurrencyRate] )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
1 year agoSuper User
Hi,
Share data in a format that can be pasted in an MS Excel file and show the expected result very clearly.
hoopaz68
1 year agoNew Member
Here is the data for the tables and expected results:
Currency_Table | |||||||
| row_uno | cruno | date | currency | rate | |||
| 1 | 100 | 9/1/2024 | USD | 1 | |||
| 2 | 100 | 9/1/2024 | GBP | 1.5161 | |||
| 3 | 100 | 9/1/2024 | EUR | 1.8946 | |||
| 4 | 101 | 9/2/2024 | USD | 1 | |||
| 5 | 101 | 9/2/2024 | GBP | 1.5475 | |||
| 6 | 101 | 9/2/2024 | EUR | 1.9116 | |||
| 7 | 102 | 9/3/2024 | USD | 1 | |||
| 8 | 102 | 9/3/2024 | GBP | 1.5421 | |||
| 9 | 102 | 9/3/2024 | EUR | 1.9177 | |||
Invoice Table | |||||||
| row_uno | cruno | inv_num | inv_date | inv_amt_usd | |||
| 1 | 100 | 4001 | 9/1/2024 | 5000 | |||
| 2 | 100 | 4002 | 9/1/2024 | 8700 | |||
| 3 | 101 | 4003 | 9/2/2024 | 2300 | |||
| 4 | 102 | 4004 | 9/3/2024 | 1500 | |||
| 5 | 102 | 4005 | 9/3/2024 | 10000 | |||
| Results | |||||||
| row_uno | cruno | inv_num | inv_date | inv_amt_usd | currency | rate | inv_amt_converted |
| 1 | 100 | 4001 | 9/1/2024 | 5,000.00 | USD | 1.0000 | 5,000.00 |
| 1 | 100 | 4001 | 9/1/2024 | 5,000.00 | GBP | 1.5161 | 7,580.50 |
| 1 | 100 | 4001 | 9/1/2024 | 5,000.00 | EUR | 1.8946 | 9,473.00 |
| 2 | 100 | 4002 | 9/1/2024 | 8,700.00 | USD | 1.0000 | 8,700.00 |
| 2 | 100 | 4002 | 9/1/2024 | 8,700.00 | GBP | 1.5161 | 13,190.07 |
| 2 | 100 | 4002 | 9/1/2024 | 8,700.00 | EUR | 1.8946 | 16,483.02 |
| 3 | 101 | 4003 | 9/2/2024 | 2,300.00 | USD | 1.0000 | 2,300.00 |
| 3 | 101 | 4003 | 9/2/2024 | 2,300.00 | GBP | 1.5475 | 3,559.25 |
| 3 | 101 | 4003 | 9/2/2024 | 2,300.00 | EUR | 1.9116 | 4,396.68 |
| 4 | 102 | 4004 | 9/3/2024 | 1,500.00 | USD | 1.0000 | 1,500.00 |
| 4 | 102 | 4004 | 9/3/2024 | 1,500.00 | GBP | 1.5421 | 2,313.15 |
| 4 | 102 | 4004 | 9/3/2024 | 1,500.00 | EUR | 1.9177 | 2,876.55 |
| 5 | 102 | 4005 | 9/3/2024 | 10,000.00 | USD | 1.0000 | 10,000.00 |
| 5 | 102 | 4005 | 9/3/2024 | 10,000.00 | GBP | 1.5421 | 15,421.00 |
| 5 | 102 | 4005 | 9/3/2024 | 10,000.00 | EUR | 1.9177 | 19,177.00 |