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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
alsm
Helper III
Helper III

Lookup value on filtered table

hello,

I have multiple tables that need to be filtered on selected date and data from different tables multiplied. Any hints?

Header Table
HeaderKeyDetailsKeyValidFromValidTo
H1D11Jan202231Dec2022
H2D215Feb202231Oct2022
H3D310Mar2022

15Sep2022

 

Details Table
DetailsKeyNameCurrencyVolume
D1AEUR500
D2BGBP700
D3CAUD250

 

Limit Table
HeaderKeyLimitVolumeValidFromValidTo
H15001Jan202215Feb2022
H145015Feb202231Mar2022
H14001Apr202231Dec2022
H270015Feb20221Mar2022
H25501Mar202231Oct2022
H325010Mar20221May2022
H32501May202215Sep2022

 

FX Table
DateCurrencyRate
31-JanCAD1.2
31-JanEUR1.1
31-JanGBP1.07
31-JanAUD1.4
31-JanUSD0.9
28-FebCAD1.3
28-FebEUR1.034
28-FebGBP1.6
28-FebAUD1.3
28-FebUSD1

 

If SelectedValue for date = 28Feb, I want to show on screen

CurrencyLimitVolumeLimitVolume (USD)
EUR450465.3
GBP7001120

 

What I have to do (if I were to write a program)

1. I have filtered HeaderTable first find what is valid on 28Feb

2. I have found all the distinct currency from Details for the header

3. I have filtered LimitTable to find LimitVolume on 28Feb

4. I have found FX rate on 28-Feb for the currencies

5. Grouped by currency shown Limit in Local currency & the convered USD value

 

No combination of lookup on filtered table to do LimitVolume*Rate seems to be working

Any other way that Lookup?

1 ACCEPTED SOLUTION
alsm
Helper III
Helper III

I solved it by adding one column after another using ADDCOLUMNS. Happy to hear from someone a more DAX like solution (this was closer to series of Lookups)

VolumeLimit (USD) = 
VAR FilteredHeaderTbl = FILTER(ALL(HeaderTbl), HeaderTbl[ValidFrom] < [SelectEoM] && HeaderTbl[ValidTo] >=[SelectEoM])
VAR FilteredNames = CALCULATETABLE(VALUES(HeaderTbl[DetailsKey]),FilteredHeaderTbl)
VAR FilteredHeaderIds = CALCULATETABLE(VALUES(HeaderTbl[HeaderKey]),FilteredHeaderTbl)
VAR FilteredLimitTbl = CALCULATETABLE(VolumeLimitTbl,FILTER(VolumeLimitTbl, VolumeLimitTbl[ValidFrom] < [SelectEoM] && VolumeLimitTbl[ValidTo] >= [SelectEoM]), FilteredHeaderIds)
VAR FilteredDetailsTbl =  CALCULATETABLE(DetailsTbl,FilteredNames)
VAR WithHeaderId = ADDCOLUMNS(FilteredDetailsTbl,"hkey",CALCULATE(MAX(HeaderTbl[HeaderKey]),FILTER(FilteredHeaderTbl, [DetailsKey] == EARLIER(DetailsTbl[DetailsKey]))))
VAR WithLimit = ADDCOLUMNS(WithHeaderId,"vol_limit", CALCULATE(MAX(VolumeLimitTbl[LimitVolume]),FILTER(FilteredLimitTbl,[HeaderKey] == EARLIER([hkey]))))
VAR WithFX = ADDCOLUMNS(WithLimit,"rate", LOOKUPVALUE(FxTbl[Rate],FxTbl[Date],[SelectEoM],FxTbl[Currency],[Currency]))
VAR TotalLimit = CALCULATE(SUMX(WithFX,[vol_limit]*[rate]))
RETURN
    TotalLimit

View solution in original post

3 REPLIES 3
alsm
Helper III
Helper III

I solved it by adding one column after another using ADDCOLUMNS. Happy to hear from someone a more DAX like solution (this was closer to series of Lookups)

VolumeLimit (USD) = 
VAR FilteredHeaderTbl = FILTER(ALL(HeaderTbl), HeaderTbl[ValidFrom] < [SelectEoM] && HeaderTbl[ValidTo] >=[SelectEoM])
VAR FilteredNames = CALCULATETABLE(VALUES(HeaderTbl[DetailsKey]),FilteredHeaderTbl)
VAR FilteredHeaderIds = CALCULATETABLE(VALUES(HeaderTbl[HeaderKey]),FilteredHeaderTbl)
VAR FilteredLimitTbl = CALCULATETABLE(VolumeLimitTbl,FILTER(VolumeLimitTbl, VolumeLimitTbl[ValidFrom] < [SelectEoM] && VolumeLimitTbl[ValidTo] >= [SelectEoM]), FilteredHeaderIds)
VAR FilteredDetailsTbl =  CALCULATETABLE(DetailsTbl,FilteredNames)
VAR WithHeaderId = ADDCOLUMNS(FilteredDetailsTbl,"hkey",CALCULATE(MAX(HeaderTbl[HeaderKey]),FILTER(FilteredHeaderTbl, [DetailsKey] == EARLIER(DetailsTbl[DetailsKey]))))
VAR WithLimit = ADDCOLUMNS(WithHeaderId,"vol_limit", CALCULATE(MAX(VolumeLimitTbl[LimitVolume]),FILTER(FilteredLimitTbl,[HeaderKey] == EARLIER([hkey]))))
VAR WithFX = ADDCOLUMNS(WithLimit,"rate", LOOKUPVALUE(FxTbl[Rate],FxTbl[Date],[SelectEoM],FxTbl[Currency],[Currency]))
VAR TotalLimit = CALCULATE(SUMX(WithFX,[vol_limit]*[rate]))
RETURN
    TotalLimit
v-yinliw-msft
Community Support
Community Support

Hi @alsm ,

 

I think you can add a column or a measure in the FX table to calculate the LimitVolume * Rate.

 

Best Regards,

Community Support Team _Yinliw

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

@v-yinliw-msft  Thank you for your reply...

I need to filter first before i do this multiply

 

so for 28Feb, the filters are

Header Table
HeaderKeyDetailsKeyValidFromValidTo
H1D11Jan202231Dec2022
H2D215Feb2022

31Oct2022

 

Details Table
DetailsKeyNameCurrencyVolume
D1AEUR500
D2BGBP700

 

Limit Table   
HeaderKeyLimitVolumeValidFromValidTo
H145015Feb202231Mar2022
H270015Feb20221Mar2022

 

FX Table  
DateCurrencyRate
28-FebEUR1.034
28-FebGBP1.6

 

and this filtered table need to be multiplied ...

problem is i cannot get my head around on how to apply complex filter (validfrom and validto) and use the result to multiply

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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