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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
gluizqueiroz
Resolver I
Resolver I

How to select value from "previous row" on a filter context with measure to create a % of Growth

On my page, I have sales in 2019 and a slicer filter with months.
Supposing that user selects February, April and June.

 

I need to create a % of Growth:
- Between February and Nothing (Because we don't have anything before).
- Between April and February (Because February is the previous month among selected months).
- Between June and April (Because April is the previous month among selected months).

 

Note that I do not want the previous month direct and yes among the selected ones.

 

First things first. I can create a % of Growth using PREVIOUSMONTH or PREVIOUSYEAR or SAMEPERIODLASTYEAR, but this case is more dynamic. If someone knows how to select previous period among the selected ones, I think I can create my % of Growth on my own.

 

To be more clear, I need something like this:

MonthSalesOnMonthPreviousMonthAmongSelectedSalesOnPreviousMonthAmongSelected% of Growth
feb/201950   
apr/2019200feb/201950300%
jun/191000apr/2019200400%
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @gluizqueiroz ,

 

I'm assuming you have a calendar table, you need to also have a endo of month column on the sales and on the calendar table (this is because I don't know how you have your model setup)

 

Create the following measure:

Previous = 
VAR Date_Selection =
    CALCULATE (
        MAX ( Sales[EndofMonth] );
        FILTER (
            ALLSELECTED ( 'Calendar' );
            'Calendar'[EndOfMonth] < MAX ( 'Calendar'[EndOfMonth] )
        )
    )
RETURN
  IFERROR (
        (
            SUM ( Sales[Sales] )
                - CALCULATE (
                    SUM ( Sales[Sales] );
                    FILTER ( ALL ( 'Calendar'[EndOfMonth] ); 'Calendar'[EndOfMonth] = Date_Selection )
                )
        )
            / CALCULATE (
                SUM ( Sales[Sales] );
                FILTER ( ALL ( 'Calendar'[EndOfMonth] ); 'Calendar'[EndOfMonth] = Date_Selection )
            );
        0
    )

Check PBIX file attach.

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @gluizqueiroz ,

 

I'm assuming you have a calendar table, you need to also have a endo of month column on the sales and on the calendar table (this is because I don't know how you have your model setup)

 

Create the following measure:

Previous = 
VAR Date_Selection =
    CALCULATE (
        MAX ( Sales[EndofMonth] );
        FILTER (
            ALLSELECTED ( 'Calendar' );
            'Calendar'[EndOfMonth] < MAX ( 'Calendar'[EndOfMonth] )
        )
    )
RETURN
  IFERROR (
        (
            SUM ( Sales[Sales] )
                - CALCULATE (
                    SUM ( Sales[Sales] );
                    FILTER ( ALL ( 'Calendar'[EndOfMonth] ); 'Calendar'[EndOfMonth] = Date_Selection )
                )
        )
            / CALCULATE (
                SUM ( Sales[Sales] );
                FILTER ( ALL ( 'Calendar'[EndOfMonth] ); 'Calendar'[EndOfMonth] = Date_Selection )
            );
        0
    )

Check PBIX file attach.

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Hey @MFelix.

Thanks for helping me Mr. Felix! 
I adapt your solution to my case and it works nice!
I didn't need to use End Of Month, because I can't. I have year, quarter and month in my matrix and it create a drill, so I need to make this dynamic and your solution guide me to achieve my goal.

Thanks thanks! 

Hi @gluizqueiroz ,

 

Glad I could help, since you didn't refer anything I just did a simple table as you add in your example.

 

No need for the Mr. :):)

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.