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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Dynamic Filtering of DAX formula that it does not go beyond Current month

I have a formula that is going beyond the time I want it to. How should I limit the formula to fall in to the scope of the past to now and not in the future.  The formula is as shown below.

 

 

SPLY INVoiced = 

CALCULATE(

    [Invoice Line TOtal],

    SAMEPERIODLASTYEAR('Date'[Date])
    )

 

 

 

Datagulf_0-1683796101733.png

The visual shows the formula in action. Since it is the sameperiodlastyear, it shows the formula going forward to 2024. I want it to show up to May 2023. How do I limit the Orange line to be span upto May 2023, the current time.


 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

I have tried to limit it as shown below, still does not work. Any suggestions?

SPLY INVoiced =
Var Month = MONTH(TODAY())
return
CALCULATE(

    [Invoice Line TOtal],SAMEPERIODLASTYEAR('Date'[Date]),FILTER('INV1 Invoice Rows', 'INV1 Invoice Rows'[DocDate] <= TODAY()

    ))

View solution in original post

Hi @Anonymous ,

 

Please try:

SPLY INVoiced =
VAR _a =
    CALCULATE ( [Invoice Line TOtal], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
RETURN
    IF ( SELECTEDVALUE ( 'Date'[Date] ) <= EOMONTH ( TODAY (), 0 ), _a )

Best Regards,

Jianbo Li

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

2 REPLIES 2
Anonymous
Not applicable

I have tried to limit it as shown below, still does not work. Any suggestions?

SPLY INVoiced =
Var Month = MONTH(TODAY())
return
CALCULATE(

    [Invoice Line TOtal],SAMEPERIODLASTYEAR('Date'[Date]),FILTER('INV1 Invoice Rows', 'INV1 Invoice Rows'[DocDate] <= TODAY()

    ))

Hi @Anonymous ,

 

Please try:

SPLY INVoiced =
VAR _a =
    CALCULATE ( [Invoice Line TOtal], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
RETURN
    IF ( SELECTEDVALUE ( 'Date'[Date] ) <= EOMONTH ( TODAY (), 0 ), _a )

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.