cancel
Showing results for
Did you mean:  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  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.

2 REPLIES 2  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.  Solution Sage

Here's something from Alberto Ferrari to this effect: https://youtu.be/d8Rm7dwM6gc Announcements #### Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories. #### Power BI Dev Camp - September 30th, 2021  