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
Anonymous
Not applicable

How to retrieve value between two tables based on multiple slicer values

I am trying to work on a scenario where I have two tables and I need to look up in table2 based on multiple slicer values coming from one table. Below are the details and your inputs are highly appreciated -

 Capture.JPG

  

The slicers will be on CompanyCode, To Currency, Rate type, date.

 

CompanyCode can be multiple selected values, and each company code will have one asscociated FromCurrency value and rest all slicers will be single select values. I don’t have a relationship between these two tables. I need to look up for a exchange rate on table2 and multiply revenue on table 1 with the exchange rate retrieved from table 2 based on slicer values.  

Basically how it works is for example - if two  company codes are selected in slicer, then we need to look up on table 2 using the two FromCurrency values that are filtered down on table 1 as each companycode will be associated with one FromCurrencyValue.

 

Right now I am able to achieve it if only one companycode is selected using below measure where I am filtering the table down to each selected value in slicer. Selected values are calculated as different measures and provided as input in below query exchangeRateCalculate -

SelectedRateType = SELECTEDVALUE(TABLE2[rate_type])

 

exchangeRateCalculate = CALCULATE(VALUES(TABLE2[exch_rate]),CALCULATETABLE(TABLE2,FILTER(TABLE2,TABLE2[fromcurrency] = [SelectedFromCurrency]) ,TABLE2[tocurrency] in VALUES(TABLE2[tocurrency]),TABLE2[rate_type] in VALUES(TABLE2[rate_type]),FILTER(TABLE2,TABLE2[rateeffectivefromdate] <= [SelectedDate] && TABLE2[rateeffectivetodate] >= [SelectedDate])

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@v-lili6-msft thanks for looking into it. My file is so large to share and I got what I wanted anyway. I was able to select multiple and filter by companycodes using AllSelected function modfiying my exisitng DAX

 

exchangeRateCalculate =

var Exch = CALCULATE(Sum(TABLE2[exch_rate]), table1(companycode in allselected (table1[Companycode]),

TABLE2[fromcurrency] in values (table1[fromcurrency] ,TABLE2[tocurrency] in VALUES(TABLE2[tocurrency]),TABLE2[rate_type] in VALUES(TABLE2[rate_type]),FILTER(TABLE2,TABLE2[rateeffectivefromdate] <= [SelectedDate] && TABLE2[rateeffectivetodate] >= [SelectedDate])

return exch

 

 

 

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

Could you please share us your sample pbix file or some sample data and the expected output. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.

 

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-lili6-msft thanks for looking into it. My file is so large to share and I got what I wanted anyway. I was able to select multiple and filter by companycodes using AllSelected function modfiying my exisitng DAX

 

exchangeRateCalculate =

var Exch = CALCULATE(Sum(TABLE2[exch_rate]), table1(companycode in allselected (table1[Companycode]),

TABLE2[fromcurrency] in values (table1[fromcurrency] ,TABLE2[tocurrency] in VALUES(TABLE2[tocurrency]),TABLE2[rate_type] in VALUES(TABLE2[rate_type]),FILTER(TABLE2,TABLE2[rateeffectivefromdate] <= [SelectedDate] && TABLE2[rateeffectivetodate] >= [SelectedDate])

return exch

 

 

 

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.