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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

FIlter Line chart DAX Formula by 1 year

Datagulf_0-1683800821257.png

I have a DAX Measure as shown below

SPLY INVoiced = 
CALCULATE(

    [Invoice Line Total],SAMEPERIODLASTYEAR('Date'[Date]))

 

The goal is to filter the 1 yr that is added so that all the line graphs end up in May 2023 rather than May 2024.

How do I change the DAX Measure to reflect that?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

After doing some extensive research, this is my answer

SPLY Sales Amount = 
IF(MONTH(TODAY()) >= SELECTEDVALUE('Date'[Month Num]) && YEAR(TODAY()) = SELECTEDVALUE('Date'[Year]),
CALCULATE(Sum('Sales'[Price]),SAMEPERIODLASTYEAR('Date'[Date])
),Blank())

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

After doing some extensive research, this is my answer

SPLY Sales Amount = 
IF(MONTH(TODAY()) >= SELECTEDVALUE('Date'[Month Num]) && YEAR(TODAY()) = SELECTEDVALUE('Date'[Year]),
CALCULATE(Sum('Sales'[Price]),SAMEPERIODLASTYEAR('Date'[Date])
),Blank())
darkinvader_
Resolver I
Resolver I

Hi @Anonymous , You can use the below formula :-

Last
Year Invoice Line Total =
VAR MaxDate
= MAX('Date'[Date])
VAR LastYearEndDate
= EOMONTH(MAX('Date'[Date]), -12)
VAR LastYearStartDate
= EOMONTH(LastYearEndDate, -11)
RETURN
CALCULATE( [Invoice Line Total],
FILTER( ALL('Date'), 'Date'[Date] >= LastYearStartDate && 'Date'[Date] <= LastYearEndDate ) )

Please do gives a thumbs up if you find it helpfull

Anonymous
Not applicable

it says there is an error.

Hi @Anonymous ,
Could you please send a Screenshot or description of the error

Anonymous
Not applicable

i have used a different method and it works fine now.. Thanks though

krishb1414
Helper III
Helper III

Hi @Anonymous  You can try this measure

SPLY INVoiced = 
VAR MaxDate = Month(Today())
VAR MinDate = Month(Today()) - 12
RETURN
CALCULATE(
    [Invoice Line Total],
    Filter(Date, 
           'Date'[Date] >= MinDate && 'Date'[Date] >= MaxDate
))


If it solves your query, Please accept it as a solution. so that someone will get help from this.

Anonymous
Not applicable

thanks @krishb1414  , I got the answer

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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