Forum Discussion
alsm
Helper III
3 years agoLookup 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 HeaderKey DetailsKey ValidFrom ValidTo H1 D1 ...
- 3 years ago
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
3 years agoHi 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.
- alsm3 years ago
Helper III
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 HeaderKey DetailsKey ValidFrom ValidTo H1 D1 1Jan2022 31Dec2022 H2 D2 15Feb2022 31Oct2022
Details Table DetailsKey Name Currency Volume D1 A EUR 500 D2 B GBP 700 Limit Table HeaderKey LimitVolume ValidFrom ValidTo H1 450 15Feb2022 31Mar2022 H2 700 15Feb2022 1Mar2022 FX Table Date Currency Rate 28-Feb EUR 1.034 28-Feb GBP 1.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