cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

DAX SAMEPERIODLASTYEAR + Filter?

Currently I'm using this DAX formula on a Card and it's working:

 

CALCULATE(
	DISTINCTCOUNT(Sales[DocumentNumber]);
	FILTER(Sales; Sales[Field1] = "1" && Sales[Field2] = VALUE(1))
)

But, I want to combine it with the function SAMEPERIODLASTYEAR, where I've tried:

 

CALCULATE(
	DISTINCTCOUNT(Sales[DocumentNumber]);
	FILTER(Sales; Sales[Field1] = "1" && Sales[Field2] = VALUE(1) && SAMEPERIODLASTYEAR (Dates[Date]))
)

 

And the result doesn't change, when it acutually has to change, so, how can I do this?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: DAX SAMEPERIODLASTYEAR + Filter?

@powerbirino

 

Please update the formula as below and try again.

 

Measure =
    CALCULATE (
        DISTINCTCOUNT ( Sales[DocumentNumber] );
        FILTER ( ALL ( Sales ); Sales[Field1] = "1" && Sales[Field2] = VALUE ( 1 ) );
        SAMEPERIODLASTYEAR ( Dates[Date] )
    )

 

Best Regards,

Herbert

View solution in original post

7 REPLIES 7
Highlighted
Microsoft
Microsoft

Re: DAX SAMEPERIODLASTYEAR + Filter?

@powerbirino

 

Please try to use following DAX formula.

 

Measure = 
    CALCULATE (
        DISTINCTCOUNT ( Sales[DocumentNumber] );
        FILTER ( Sales; Sales[Field1] = "1" && Sales[Field2] = VALUE ( 1 ) );
        SAMEPERIODLASTYEAR ( Dates[Date] )
    )

 

Best Regards,

Herbert

Highlighted
Frequent Visitor

Re: DAX SAMEPERIODLASTYEAR + Filter?

@v-haibl-msft

 

Trying that gives (Blank), which is incorrect because it should give a digit.

 

I know it's wrong because filtering by 2014 the result in the "Current year" Card visual (for instance) gives 3000, and the same visual filtering by 2013 gives 800, but, using the "Last year" Card visual and filtering by 2014 with your solution, gives (Blank), when it should give 800.

 

I have tried other solutions but I can't achieve this dumb thing 😕

Highlighted
Microsoft
Microsoft

Re: DAX SAMEPERIODLASTYEAR + Filter?

@powerbirino

 

Please update the formula as below and try again.

 

Measure =
    CALCULATE (
        DISTINCTCOUNT ( Sales[DocumentNumber] );
        FILTER ( ALL ( Sales ); Sales[Field1] = "1" && Sales[Field2] = VALUE ( 1 ) );
        SAMEPERIODLASTYEAR ( Dates[Date] )
    )

 

Best Regards,

Herbert

View solution in original post

Highlighted
Frequent Visitor

Re: DAX SAMEPERIODLASTYEAR + Filter?

It was that!

 

Thank you!!

Highlighted
Regular Visitor

Re: DAX SAMEPERIODLASTYEAR + Filter?

Hi, please , i was trying a formular for:  calculate , in sameperiodlastyear but with removing the day 29 of April (2019 not exsiting),

whihc one i have to use?

Highlighted
Regular Visitor

Re: DAX SAMEPERIODLASTYEAR + Filter?

LastYearAmount = CALCULATE(BaseAmount,SAMEPERIODLASTYEAR('calendartable'[Date])) This is my formular that imusing for the moment
Highlighted
Frequent Visitor

Re: DAX SAMEPERIODLASTYEAR + Filter?

Can i apply SAMEPERIODLASTYEAR on a measure? How?

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (44)