Forum Discussion
multiple values from different table and show previous month value
- 5 years ago
Hi, viralpatel21
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
FX Rate:
Month fx:
There is a relationship between two tables based on 'Months' column. You may create two measures as below.
Measure SUM fx RATE x EUR = SUMX( SUMMARIZE( 'Month fx', 'Month fx'[Months], "Result", var m = MAX('Month fx'[MonthValue]) var lastmonth = CALCULATE( MAX('Month fx'[MonthValue]), FILTER( ALL('Month fx'), [MonthValue]<m ) ) var eurfx = CALCULATE( SUM('FX Rate'[EUR_Avg]), FILTER( ALL('FX Rate'), [MonthValue]=lastmonth ) ) var eurmfx = CALCULATE( SUM('Month fx'[EUR_Avg]), FILTER( ALL('Month fx'), [MonthValue]=lastmonth ) ) return IF( ISBLANK(SUM('FX Rate'[EUR_Avg]))||ISBLANK(SUM('Month fx'[EUR_Avg])), eurfx*eurmfx, SUM('FX Rate'[EUR_Avg])*SUM('Month fx'[EUR_Avg]) ) ), [Result] )Measure SUM fx RATE x GBP = SUMX( SUMMARIZE( 'Month fx', 'Month fx'[Months], "Result", var m = MAX('Month fx'[MonthValue]) var lastmonth = CALCULATE( MAX('Month fx'[MonthValue]), FILTER( ALL('Month fx'), [MonthValue]<m ) ) var gbpfx = CALCULATE( SUM('FX Rate'[EUR_Avg]), FILTER( ALL('FX Rate'), [MonthValue]=lastmonth ) ) var gbpmfx = CALCULATE( SUM('Month fx'[EUR_Avg]), FILTER( ALL('Month fx'), [MonthValue]=lastmonth ) ) return IF( ISBLANK(SUM('FX Rate'[GBP_Avg]))||ISBLANK(SUM('Month fx'[GBP_Avg])), gbpfx*gbpmfx, SUM('FX Rate'[GBP_Avg])*SUM('Month fx'[GBP_Avg]) ) ), [Result] )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, viralpatel21
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
FX Rate:
Month fx:
There is a relationship between two tables based on 'Months' column. You may create two measures as below.
Measure SUM fx RATE x EUR =
SUMX(
SUMMARIZE(
'Month fx',
'Month fx'[Months],
"Result",
var m = MAX('Month fx'[MonthValue])
var lastmonth =
CALCULATE(
MAX('Month fx'[MonthValue]),
FILTER(
ALL('Month fx'),
[MonthValue]<m
)
)
var eurfx =
CALCULATE(
SUM('FX Rate'[EUR_Avg]),
FILTER(
ALL('FX Rate'),
[MonthValue]=lastmonth
)
)
var eurmfx =
CALCULATE(
SUM('Month fx'[EUR_Avg]),
FILTER(
ALL('Month fx'),
[MonthValue]=lastmonth
)
)
return
IF(
ISBLANK(SUM('FX Rate'[EUR_Avg]))||ISBLANK(SUM('Month fx'[EUR_Avg])),
eurfx*eurmfx,
SUM('FX Rate'[EUR_Avg])*SUM('Month fx'[EUR_Avg])
)
),
[Result]
)Measure SUM fx RATE x GBP =
SUMX(
SUMMARIZE(
'Month fx',
'Month fx'[Months],
"Result",
var m = MAX('Month fx'[MonthValue])
var lastmonth =
CALCULATE(
MAX('Month fx'[MonthValue]),
FILTER(
ALL('Month fx'),
[MonthValue]<m
)
)
var gbpfx =
CALCULATE(
SUM('FX Rate'[EUR_Avg]),
FILTER(
ALL('FX Rate'),
[MonthValue]=lastmonth
)
)
var gbpmfx =
CALCULATE(
SUM('Month fx'[EUR_Avg]),
FILTER(
ALL('Month fx'),
[MonthValue]=lastmonth
)
)
return
IF(
ISBLANK(SUM('FX Rate'[GBP_Avg]))||ISBLANK(SUM('Month fx'[GBP_Avg])),
gbpfx*gbpmfx,
SUM('FX Rate'[GBP_Avg])*SUM('Month fx'[GBP_Avg])
)
),
[Result]
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.