cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

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

Accepted Solutions
Highlighted

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
Highlighted
Super User IV
Super User IV

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!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Microsoft
Microsoft

Hi @Samrawit21,

 

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.
Highlighted

@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

Highlighted

Hi @Samrawit21,

 

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.
Highlighted

@v-jiascu-msft Thanks for your reply!

Below is my sample file 

Capture2.PNG

 

Capture 3.PNG

Highlighted

Hi @Samrawit21,

 

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.
Highlighted

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))

 

 

Highlighted

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors