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

Calculate YTD by selected value and show all moths

Hi guys,

 

I need to show YTD values by selected Date value field and show all values to each month until the selected month. This measure is only if type = A, So if the user selected type = A,  and date 202104 the expected result is:
For types differents of A, I need to show all values until the Date selected and not the only YTD.

Type Month    Value
A      202101   10
A      202102    20
A      202103    30
A      202104    40
A     202012      0
A     202011      0
A     202010      0
B     202101     100

B    202012       200
B    201907     200

Total       600




1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@twister8889 
Plenty things you need to do. Please check the pbix for detail:

 

1. Create a date column, and use the date column instead of month column to filter

Date = DATE(LEFT([Month],4),RIGHT([Month],2),01)
 
2. Create a separate table to be used as slicers:
Table 2 = SUMMARIZECOLUMNS('Table'[Type],'Table'[Date])
 
3. Create a result measure:
Measure = IF(SELECTEDVALUE('Table 2'[Type])="A",
TOTALYTD(SUM([Value]),'Table'[Date],FILTER('Table',[Type]=SELECTEDVALUE('Table 2'[Type]) && [Date]<=SELECTEDVALUE('Table 2'[Date]))),
CALCULATE(SUM('Table'[Value]),ALL('Table')))

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@twister8889 
Plenty things you need to do. Please check the pbix for detail:

 

1. Create a date column, and use the date column instead of month column to filter

Date = DATE(LEFT([Month],4),RIGHT([Month],2),01)
 
2. Create a separate table to be used as slicers:
Table 2 = SUMMARIZECOLUMNS('Table'[Type],'Table'[Date])
 
3. Create a result measure:
Measure = IF(SELECTEDVALUE('Table 2'[Type])="A",
TOTALYTD(SUM([Value]),'Table'[Date],FILTER('Table',[Type]=SELECTEDVALUE('Table 2'[Type]) && [Date]<=SELECTEDVALUE('Table 2'[Date]))),
CALCULATE(SUM('Table'[Value]),ALL('Table')))

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

daxer
Solution Sage
Solution Sage

Here's something from Alberto Ferrari to this effect: https://youtu.be/d8Rm7dwM6gc

 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors