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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

YTD and YTD prior with filter

Hello, Please I need help to fix this.

I used the following formulas to create a measure for YTD and YTD LY

ll YTD = CALCULATE(SUM('Transaktion'[konto]),FILTER('Transaktion',[Datum]>=DATE(YEAR(TODAY()),1,1) && [Datum] <=(DATE(YEAR(TODAY()),MONTH(TODAY()),1)-1)))

 

ll YTD  LY= CALCULATE(SUM('Transaktion'[konto]),FILTER('Transaktion',[Datum]>=DATE(YEAR(TODAY())-1,1,1) && [Datum] <=(DATE(YEAR(TODAY())-1,MONTH(TODAY()),1)-1)))

 

when I choose the year 2018 in the year slicer I also want to see YTD LY(YTD value for 2017), but it only shows me YTD(for 2018)

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I created a separate date table and I created a column 

Today = DATE(YEAR('Table'[Date]),MONTH(TODAY()),1)-1

and to find a YTD I used the formula

ll YTD = TOTALYTD(SUM('Transaktion'[konto]),'Table'[Date],FILTER(ALL('Table'[Date]),'Table'[Date] <= MAX('Table'[Today])))

 and to find YTD LY 

ll YTD LY = VAR DataMaxDate =CALCULATE ( MAX ( 'Transaktion'[Datum] ), ALL ( 'Transaktion' ) )
RETURN
CALCULATE ([ll YTD],SAMEPERIODLASTYEAR (INTERSECT (VALUES ( 'Table'[Date] ),DATESBETWEEN ( 'Table'[Date], BLANK (), DataMaxDate ))))and it works fine!

Thank you for your replies!

 

View solution in original post

8 REPLIES 8
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

How did you use these formulas? In other words, what's the context? Can you share a sample file?

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft

I created this measures to get YTD values until the end of last month and LY YTD for the same period( last year until the end of  last month e.g September)

Below is my sample file

InkedCapture_LI.jpg

Hi @Anonymous,

 

Your sample is a result which we can't use it to find the root cause. Can you share a dummy sample? 

BTW, it seems you selected the year 2017 and there isn't the year 2016. Maybe that's why the YTD LY is empty.

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft Thanks for your reply!

Below is my sample file 

Capture2.PNG

 

Capture 3.PNG

Hi @Anonymous,

 

There isn't any data in the year 2017. For example, IKB 2020. there isn't any data of IKB 2020 in the year 2017. What's the expected value?

Please also check out the demo in the attachment. If it's the desired result.

YTD-and-YTD-prior-with-filter

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-jiascu-msft

 

I edited the formula by adding ALL function, and now it shows me YTD LY when I select 2018 I, but for each row, it shows the same value(total of YTD LY), instead of showing the actual YTD LY values for each IKB and put the total below.

 

What I want to see is, when I select each year I want to see the year to date value for the selected year and the year before.IKB like an organization number.

 

ll YTD LY = CALCULATE(SUM('Transaktion'[konto]),FILTER(all('Transaktion'),[Datum]>=DATE(YEAR(TODAY())-1,1,1) && [Datum] <=date(YEAR(TODAY()),MONTH(TODAY()),1)-1))

 

 

Anonymous
Not applicable

I created a separate date table and I created a column 

Today = DATE(YEAR('Table'[Date]),MONTH(TODAY()),1)-1

and to find a YTD I used the formula

ll YTD = TOTALYTD(SUM('Transaktion'[konto]),'Table'[Date],FILTER(ALL('Table'[Date]),'Table'[Date] <= MAX('Table'[Today])))

 and to find YTD LY 

ll YTD LY = VAR DataMaxDate =CALCULATE ( MAX ( 'Transaktion'[Datum] ), ALL ( 'Transaktion' ) )
RETURN
CALCULATE ([ll YTD],SAMEPERIODLASTYEAR (INTERSECT (VALUES ( 'Table'[Date] ),DATESBETWEEN ( 'Table'[Date], BLANK (), DataMaxDate ))))and it works fine!

Thank you for your replies!

 

Greg_Deckler
Super User
Super User

You will have to use an ALL or ALLSELECTED in your YTD LY calculation. 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...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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