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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
LaurenceSD
Advocate II
Advocate II

remove future dates from sameperiod last year calc

Hi,

 

I'm struggling with this, despite trying numerous suggestions

 

These are my formulas so far

 

Bookings = DISTINCTCOUNT(BOOKINGS[BookId])
Bookings LY (Bk date) = CALCULATE(BOOKINGS[Bookings],SAMEPERIODLASTYEAR('DATESBKGS&ENQS'[Dates-Bkg&Enq].[Date]))
Bookings V LY (Bk date) = if(ISBLANK([Bookings LY (Bk date)]),BLANK(),BOOKINGS[Bookings]-BOOKINGS[Bookings LY (Bk date)])
 
I've managed to successfully stop the 2018 calculation being against something blank, but I can't for the life of me find a way around getting rid of the 2022 and also the Feb 2021 onwards should also be blank
 
I've tried adding a calculated column into my date table that returns a True or falls for is the date is before today and using that to filter, but it seems to make no effect. Any ideas where I'm going wrong?

 

I've got a slicer in play on this page, so the user can expand their time period as necessary. Thanks

 

LaurenceSD_0-1611581348055.png

 

Thanks

 

1 ACCEPTED SOLUTION
LaurenceSD
Advocate II
Advocate II

so i believe i've found a solution, which, I stumbled upon by accident which was removing the .date

 

So changing this

 

Bookings LY (Bk date) = CALCULATE(BOOKINGS[Bookings],SAMEPERIODLASTYEAR('DATESBKGS&ENQS'[Dates-Bkg&Enq].[Date]))

 

to 

 

Bookings LY (Bk date) = CALCULATE(BOOKINGS[Bookings],SAMEPERIODLASTYEAR('DATESBKGS&ENQS'[Dates-Bkg&Enq]))

 

Seem to work, I'm guessing it must have something to do with the time intelligence function, but thought i'd post for anyone else who may have a similar querey

View solution in original post

5 REPLIES 5
LaurenceSD
Advocate II
Advocate II

so i believe i've found a solution, which, I stumbled upon by accident which was removing the .date

 

So changing this

 

Bookings LY (Bk date) = CALCULATE(BOOKINGS[Bookings],SAMEPERIODLASTYEAR('DATESBKGS&ENQS'[Dates-Bkg&Enq].[Date]))

 

to 

 

Bookings LY (Bk date) = CALCULATE(BOOKINGS[Bookings],SAMEPERIODLASTYEAR('DATESBKGS&ENQS'[Dates-Bkg&Enq]))

 

Seem to work, I'm guessing it must have something to do with the time intelligence function, but thought i'd post for anyone else who may have a similar querey

iXpert_info
Helper II
Helper II

Hello @LaurenceSD 

You can simply create a measure as follows

Bookings CY = Calculate(DistinctCount(BookingsID),

,DATESBETWEEN(Ops_Dashboard[RouteDate],DATE(YEAR(TODAY()),1,1),TODAY()))

)

Other Measures should be good

Did I answer your question? If Yes Please mark this as solution

Best Regards
Jay Patel
iXpert Analytics

Hi Jay,

 

That doesn't seem to work, seems to reproduce the current year for every single year

 

LaurenceSD_0-1611586231604.png

 

What I'm ideally trying to show is the year on year variation with year going across the top and months down the side. And what I've done so far works fine for dates in the past, I just can't seem to find a way of stopping Feb 21 being compared to Feb 20, because Feb 21 hasn't happened yet.

Greg_Deckler
Super User
Super User

@LaurenceSD Seems like you need to add a check of something like IF([Date]>TODAY(),BLANK(),...)

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Yeah that was my thinking as well, I tried 

Bookings LY (Bk date) = if(SELECTEDVALUE('DATESBKGS&ENQS'[Dates-Bkg&Enq].[Date])>TODAY(),BLANK(),CALCULATE(BOOKINGS[Bookings],SAMEPERIODLASTYEAR('DATESBKGS&ENQS'[Dates-Bkg&Enq].[Date]))) & it doesn't seem to produce a result that's any different - any further thoughts on where I'm going wrong?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors