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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Get the value from a column based on a filter in another column

Hello, 

I am trying to create a measure to get the sales value of two columns in another table that is linked to my fact table (previous month and previous scenario), so in the example below, for key 0 (M1-1) the value I need to fetch is (M12-2) which is 200. I have tried multiple solutions but none gave me a result. Last I tried was the below:

 

Sell Previous Month =
   SUMX(
      FILTER(
         fSales,
         fSales[Month] = RELATED(DimMonth[Previous_Month])
      ),
      SUM(fSales[Sales])
   )

 

KeyMonthScenarioSalesSales_Previous_Month
0M11100200
1M21500 
2M31600 
3M41200 
4M51400 
5M12150 
6M22150 
7M32300 
8M42150 
9M52200 
10M62200 
11M72200 
12M82200 
13M92200 
14M102200 
15M112200 
16M122200 

 

KeyMonth ScenarioPrevious_MonthPrevious_Scenario
0M11M122
1M21M11
2M31M21
3M41M31
4M51M41
5M12NANA
6M22M1NA
7M32M2NA
8M42M3NA
9M52M4NA
10M62M5NA
11M72M6NA
12M82M7NA
13M92M8NA
14M102M9NA
15M112M10NA
16M122M11NA

 

Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. Create calculated column.

Sell Previous Month  =
var _m=
MAXX(
    FILTER(ALL(DimMonth),'DimMonth'[Key]=EARLIER('fSales'[Key])&&'DimMonth'[Month ]=EARLIER('fSales'[Month])),[Previous_Month])
var _Scenario=
MAXX(
    FILTER(ALL(DimMonth),'DimMonth'[Key]=EARLIER('fSales'[Key])&&'DimMonth'[Month ]=EARLIER('fSales'[Month])),[Previous_Scenario])
return
MAXX(
    FILTER(ALL('fSales'),
'fSales'[Month]=_m&&'fSales'[Scenario]=_Scenario),[Sales])

2. Result:

vyangliumsft_0-1684144069872.png

 

Best Regards,

Liu Yang

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

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. Create calculated column.

Sell Previous Month  =
var _m=
MAXX(
    FILTER(ALL(DimMonth),'DimMonth'[Key]=EARLIER('fSales'[Key])&&'DimMonth'[Month ]=EARLIER('fSales'[Month])),[Previous_Month])
var _Scenario=
MAXX(
    FILTER(ALL(DimMonth),'DimMonth'[Key]=EARLIER('fSales'[Key])&&'DimMonth'[Month ]=EARLIER('fSales'[Month])),[Previous_Scenario])
return
MAXX(
    FILTER(ALL('fSales'),
'fSales'[Month]=_m&&'fSales'[Scenario]=_Scenario),[Sales])

2. Result:

vyangliumsft_0-1684144069872.png

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

hi @Anonymous , I did a few modifications on the equation above and the logic more or less works. One issue I face is that I noticed I get no values when the value of the month itself does not exist. For example in the table below I have no value for M2 Scenario one, so for some reason the previous month also comes out with no value although it should still show 100. What could be the reason for that?

KeyMonthScenarioSalesSell Previous Month
0M11100200
1M21  
2M31600500
3M41200600
4M51400200
5M12150 
6M22150 
7M32300 
8M42150 
9M52200 
Anonymous
Not applicable

Hi @Anonymous, thanks a lot this indeed works but there is one step I forgot to mention. So this does give me the previous month-scenario sales but there are many other unique keys in the table (products), so what it does is actually brings the value from previous month for another product, how can I include the product key information in the code above. Thank you!

Anonymous
Not applicable

actually I managed to add all the row key information in the last filter as done with the two variables above. All good now! Thanks a lot!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.