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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
paulinamaj
Frequent Visitor

sameperiodlastyear and % change

Hello,

I have a problem with formula "sameperiodlastyear" and % change last period. It shows wrong value when the period (month, quater, year) is not chosen on slicer.

1) I created a date table using the calendar function of Powerbi.

2) I added a function: 

Lastyearperiod = CALCULATE('Sales Valus PLN'[Total sales], SAMEPERIODLASTYEAR('Timedimension'[Date]))
3) then:
% last period = CALCULATE( DIVIDE( 'Sales Valus PLN'[Total sales] - [Lastyearperiod], [Lastyearperiod]))
 
It works great until I dont chose period (month, quater, year) on slicer. If a slicer contains all periods it shows a wrong value. I want to add a funcion if date is not chosen show blank, but I really dont how. Please help me.
I created a relationship beetween columns:
paulinamaj_0-1623173044565.png

 

Any tips on where I'm going wrong here would be hugely appreciated.
 
4 REPLIES 4
paulinamaj
Frequent Visitor

@parry2k thank you for your tips, it's my first post here. Sorry for mistake.

parry2k
Super User
Super User

@paulinamaj you never clarified, you mentioned that you are selecting a date and now you have totally different explanation. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@paulinamaj you can tweak your measure like this:

 

% last period = 
IF ( HASONEVALUE ( YourDateTable[DateColumn] ),
CALCULATE( DIVIDE( 'Sales Valus PLN'[Total sales] - [Lastyearperiod], [Lastyearperiod]))
)

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi, @parry2k thank you. But now it stopped working correcly, shows non value for all year, only for last year of date (I have to choose month, quater, year on slicer). 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

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