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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
GFRASER
Regular Visitor

Use Column Value to choose which column of another table to lookup

Hello

I am trying to get EXCHRATE in the first table to lookup an FX table that has the various periods in the rows and the columsn are the different currencies.

I want the lookup rather than using "EUR" which is currently hardcoded in the formula to use the value from Column2 in the first visual/table.

 

Potentially a better way of getting the FX rates but they are on this table currently so was trying to pull from there without much luck?

 

If you're feeling generous where the Period number is hardcoded as 9 currently ideally want that pulling from a slicer selection if there's a way of doing that?

 

All help gratefully appreciated.

 

Thanks

 

 

GFRASER_0-1714748311213.pngGFRASER_2-1714748362206.png

GFRASER_1-1714748335658.png

 

 

1 ACCEPTED SOLUTION

@lbendlin Thanks for your contribution on this thread.

Hi @GFRASER ,

You can follow the steps below to get the expected result, please find the details in the attachment.

1. Unpivot these columns of table 'FX' except the column 'Period' in Power Query Editor

= Table.Unpivot(#"Changed Type", {"EUR", "CAD", "CZK", "PLN"}, "Currency", "Value")

vyiruanmsft_0-1715073780276.png

2. Create a slicer and apply the field [Period] of table 'FX'

3. Create a measure as below to get the exchange rate base on different period and currency

EXCHRATE =
VAR _period =
    SELECTEDVALUE ( 'FX'[Period] )
VAR _currency =
    SELECTEDVALUE ( 'Table'[CURRENCY] )
RETURN
    CALCULATE (
        MAX ( 'FX'[Value] ),
        FILTER ( 'FX', 'FX'[Period] = _period && 'FX'[Currency] = _currency )
    )

vyiruanmsft_1-1715073974960.png

Best Regards

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

View solution in original post

4 REPLIES 4
GFRASER
Regular Visitor

Thanks for the advice.  I am trying to find a way to lookup the EXCHRATE value in the table below from the FX table.  I need it to look up the CURRENCY field in the FX table.  If I can get it to pick the Period based on a slicer or something that would be good, otherwise I can filter the FX table with a global slicer so only the period required is showing in the table.

 

If for example purposes we say the period is 7 then I'd expect the Currencies with EUR to return 1.1567, CAD 1.6878, CZK 28.3698 in the EXCHRATE field.

 

Thanks

 

DATAAREACURRENCYEXCHRATE
AUTEUR1.1682
BELEUR1.1682
CANCAD1.1682
CZECZK1.1682
EUTEUR1.1682
GEREUR1.1682
HOLEUR1.1682
IRLEUR1.1682
LIVGBP1.1682
NEVGBP1.1682
PO1PLN1.1682
PO2PLN1.1682
POLPLN1.1682
SVKEUR1.1682
TDPPLN1.1682
TELGBP1.1682
TILGBP1.1682
TLLGBP1.1682
TOLGBP1.1682
TRPGBP1.1682
TSLGBP1.1682
USAUSD1.1682

 

 

FX LOOKUP TABLE

PeriodEURCADCZKPLN
71.15671.687828.36985.017
Average1.1613731.69908228.569075.1249
81.16651.716528.87865.128
91.16821.706429.65765.0385

 

 

@lbendlin Thanks for your contribution on this thread.

Hi @GFRASER ,

You can follow the steps below to get the expected result, please find the details in the attachment.

1. Unpivot these columns of table 'FX' except the column 'Period' in Power Query Editor

= Table.Unpivot(#"Changed Type", {"EUR", "CAD", "CZK", "PLN"}, "Currency", "Value")

vyiruanmsft_0-1715073780276.png

2. Create a slicer and apply the field [Period] of table 'FX'

3. Create a measure as below to get the exchange rate base on different period and currency

EXCHRATE =
VAR _period =
    SELECTEDVALUE ( 'FX'[Period] )
VAR _currency =
    SELECTEDVALUE ( 'Table'[CURRENCY] )
RETURN
    CALCULATE (
        MAX ( 'FX'[Value] ),
        FILTER ( 'FX', 'FX'[Period] = _period && 'FX'[Currency] = _currency )
    )

vyiruanmsft_1-1715073974960.png

Best Regards

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

Thanks Rena

I've got that working now. 

Can I ask how I would use the output of this measure?

 

I have the table below where it has the DATAAREA in this case BEL, which per the Table called 'Table' in this scenario we know uses currency EUR.  I am tring to create a New Column in the table below called GBPCURRENCYAMOUNT which takes the field ACCOUNTINGCURRENCYAMOUNT and divides it by the exchange rate picked up in EXCHRATE.

 

It is calculating in this example but when I change the slicer associated with EXCHRATE it doesn't update this amount for the different exchange rate.  Not sure how I get it to dynamically link to EXCHRATE?

 

Thanks

 

DATAAREANominal Sum of ACCOUNTINGCURRENCYAMOUNT  Sum of GBPCURRENCYAMOUNT 
BEL11200                                                                     68,710.32                                                 59,120.91
BEL11230-                                                                   68,710.32-                                               59,120.91
BEL11300                                                                     44,075.80                                                 37,924.45
BEL11330-                                                                   44,075.80-                                               37,924.45
BEL11400                                                                       1,302.15                                                   1,120.42
BEL11430-                                                                     1,302.15-                                                 1,120.42
BEL11500                                                                                    -                                                                  -  
BEL11530                                                                                    -                                                                  -  
BEL11700                                                                                    -                                                                  -  
BEL11730                                                                                    -                                                                  -  
BEL13100                                                                     78,305.88                                                 67,195.18
BEL13110-                                                                     1,377.00-                                                 1,184.82
BEL14100                                                                     22,056.56                                                 18,978.28
BEL14300-                                                                 147,319.85-                                             126,853.26
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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