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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sameperodlast year not working with custom date field on slicer

I have custom field in my slicer for FY19,FY20,F21 coming from the date table and I need to use SamePeriodLastYear in the calculation, but keep filtering by my slicer above.

 

Because I'm not using the date field on the slicer the calculation isn't working.

 

Any ideas how to fix?

 

please see below :

 

Invoiced Revenue PY =
var result =
CALCULATE( [Invoiced Revenue],
SAMEPERIODLASTYEAR(DimDate[Date])
)
RETURN
IF(
HASONEVALUE(DimDate[Financial_Year_short]),
result, 0
)
 

 

 

 

fabnishi1207_0-1616987638730.png

 

Thanks

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Just in case, please check if your DimDateTable is assigned as a date-table.

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Just in case, please check if your DimDateTable is assigned as a date-table.

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Hi,

 

Thanks for that.

 

The table actually wans't assiged as Data because I had one gap between the dates.

 

I remove the first row which was the gap from 01/01/1900 then Assiged again as date table and now it's working.

 

Thanks a lot.

 

 

amitchandak
Super User
Super User

@Anonymous , I am not sure about the need on hasonevalue here.

isfiltered or isinscope are better alternates

 

Invoiced Revenue PY =
var result =
CALCULATE( [Invoiced Revenue],
SAMEPERIODLASTYEAR(DimDate[Date])
)
RETURN
IF(
isinscope(DimDate[Financial_Year_short]),
result, 0
)

 

or simply use

 

Invoiced Revenue PY =
CALCULATE( [Invoiced Revenue],
SAMEPERIODLASTYEAR(DimDate[Date])
)

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

 

Other than there can a few other reasons Time intelligence can fail

Check https://www.youtube.com/watch?v=OBf0rjpp5Hw

Anonymous
Not applicable

Hi,

 

Thanks for getting back to me.

 

But still not working. Forget about the is in scope, if I only use the sameperiod last year also is not working.

 

For some reason the calculation only works when I the column with Financial_year_short is not in the visual.

 

See below:

 

When I aggregate with the column I need, it's weird because it shows me the total only. 

 

fabnishi1207_1-1616993350951.png

 

 

Now without the Financial Year Short (column I need to aggregate the PY values)

fabnishi1207_2-1616993379101.png

 

The issue is when I bring the Financial_year_short that I need.

 

This columns is a simple column from the date table saying which fiscal year is the date.

 

 

 

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.