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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Getting actual value as YTD value on inserting a filter

Hi,

I needed to calculate YTD value for a group of Units for two different year and I was able to do and plot a graph. The formulae I used was 
YTDXYX = CALCULATE(SUM(Data[XYX days]);FILTER(ALLSELECTED(Data[Month]);'Data'[Month]<=MAX('Data'[Month])))

 

This gave me data based on month and the value I see in my tabular column is like this which is correct:

Month  2017   2018
1             123     110

2             312      253

3             444      375

4             516      500              and so on... Now this value is correct and I have no issue.

But when I try to filter out and put a visual level filter just for Month like Month is 4 in the above tabular column

I get data as

Month   2017    2018
4             72        125           which is the actual value and not the YTD value. May I know what is causing this issue . I need to put the actual month and get the YTD for different Units and so this filter is important.

Its not behaving correctly though.

Please advice.

Regards,
Ankku

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

=CALCULATE(SUM(Data[XYX days]);DATESYTD(Calendar[Date];"31/12"))

 

Please note the following:

 

  1. I have assumed that the year ending date is 31 December.  If it is 30 June, then change the last input to "30/6"
  2. There should be a Calendar Table with a relationship from the Date column fo the Data Table to the Date column of the Calendar Table
  3. In the Calendar Table, write these calculated column formulas to extract the Year and Month =YEAR(Calendar[Date]) and =FORMAT(Calendar[Date],"mmmm")
  4. In your visual/filter, drag the Year/month column from the Calendar Table

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

This is due to the function ALLSELECTED(), the visual level filter will affect the measure values. 

 

To get the value:

 

Month   2017    2018
4             516       500

 

You can replace the ALLSELECTED() function with ALL() function,  so the new measure is

 

YTDXYX = CALCULATE(SUM(Data[XYX days]);FILTER(ALL(Data[Month]);'Data'[Month]<=MAX('Data'[Month])))

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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-qiuyu-msft,

I still see something is wrong in here. if you see my graph here I get the value as YTD in the graph as below. Please see the value for month 4. The value in graph is different and some other value when I put a filter on month 4. Even in graph if I put the filter as Month 4 I get the same value as in tabular column. But without filter there is a different value in the graph as you can see. What am I missing??

1.JPG

 

2.JPG

Hi @Anonymous,

 

Please share pbix file with us if possible. 

 

Best Regards,
Qiuyun Yu

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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