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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

Anonymous
Not applicable

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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