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
tchen0
Regular Visitor

TotalYTD is not working as I expected

I have been trying to get TotalYTD work.   See the data and formula below :

 

  1) For YTD Act, YTD_Fcst and YTD Var, TotalYTD is working as expected.

  2) For YTD Var Abs, TotalYTD is not working as expected.  I can not figure out why only this one is not working properly.

 

Thanks

 

       ??? 
    =totalYTD('OP - Data'[Actual], 'Date Key'[Date_key])=totalYTD('OP - Data'[Fcst], 'Date Key'[Date_key])=totalYTD( 'OP - Data'[Var], 'Date Key'[Date_key])=totalYTD ('OP - Data'[Var Abs],  'Date key'[Date_key]) 
Actual = CALCULATE(sum('OP - Data'[Fcst_Act]),  filter('OP - Data', 'OP - Data'[Fcst_N]=0 && 'OP - Data'[Fcst Type]="Actual"))Fcst = CALCULATE(sum('OP - Data'[Fcst_Act]), filter('OP - Data','OP - Data'[Fcst_N]=4 && 'OP - Data'[Fcst Type]="Fcst" ))New MeasureNew Measureworkingworkingworkingnot workingNeed to be
ActualFcstVar  (= Actual - Fcst)Var Abs (= abs(Actual - Fcst)  )YTD ActYTD_FcstYTD VarYTD Var Abs YTD Var Abs
726,247467,896258,351258,351726,247467,896258,351258,351258,351
653,244572,12481,12081,1201,379,4911,040,020339,471339,471339,471
513,018606,354-93,33693,3361,892,5091,646,374246,135246,135432,807
367,854629,864-262,010262,0102,260,3632,276,238-15,87515,875694,817
         
1 ACCEPTED SOLUTION

Hi,

 

In your Matrix visual, i dragged Month from the Date Table to the Rows section.  I wrote the folloing measure

 

YTD Var Abs = if(ISBLANK([Var Abs]),BLANK(),SUMX(CALCULATETABLE(SUMMARIZE(ALL('Date'[Month]),'Date'[Month],"ABCD",[Var Abs]),DATESBETWEEN('Date'[Date_key],DATE(YEAR(MAX('Date'[Date_key])),1,1),MAX('Date'[Date_key]))),[ABCD]))

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

12 REPLIES 12
Ashish_Mathur
Super User
Super User

Hi,

 

Aren't your last two numbers in the last column incorrect.  The second last row's answer should remain 246,135 and the last row's answer should be 15,875.  How can the answer be 694,817?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

They are correrct. 

 

694,817 = 258,351+81,120+93,336+262,010

 

Please refer to the fourth column. Thanks. 

Hi,

 

Your picture is not clear.  Is your last row a Grand Total row.  Share the link from where i can download your PBI workbook and show the table where you want the result to appear.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

See the example I created:

https://1drv.ms/u/s!AowzPecIR5bZhiJTAAlG0svwbiA5

 

 

The column "YTD Var Abs" is not calculating right. 

 

Any thoughts? Thanks. 

 

 

Hi,

 

I believe this is the answer you are expecting.  This is my measure

 

=YTD Var Abs = if(HASONEVALUE('Date'[Date_key].[Month]),if(max('Date'[Date_key])<now(), totalYTD('Data'[Var Abs],'Date'[Date_key]),blank()),SUMX(SUMMARIZE(VALUES('Date'[Date_key].[Month]),[Date_key].[Month],"ABCD",if(max('Date'[Date_key])<now(), totalYTD('Data'[Var Abs],'Date'[Date_key]),blank())),[ABCD]))

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you for your reply.  It does not get what I expect.  I want "YTD Var Abs" to be calcuated based on the column - "Var Abs".  

 

2018    not working  
MonthActualFcstVarVar AbsYTD VarYTD Var Abs ( incorrect)YTD Var Abs I expect to be
156-11-111=1
26511002 =(1+1)
348-44-446 =(1+1+4 )
4101000-446 =(1+1+4+0)
59811-337 =(1+1+4+0+1)
6       
7       
8       
9       
10       
11       
12       

Hi,

 

In your Matrix visual, i dragged Month from the Date Table to the Rows section.  I wrote the folloing measure

 

YTD Var Abs = if(ISBLANK([Var Abs]),BLANK(),SUMX(CALCULATETABLE(SUMMARIZE(ALL('Date'[Month]),'Date'[Month],"ABCD",[Var Abs]),DATESBETWEEN('Date'[Date_key],DATE(YEAR(MAX('Date'[Date_key])),1,1),MAX('Date'[Date_key]))),[ABCD]))

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks. It works!!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Also see the problem below: 

 

 2018    not working 
MonthActualFcstVarVar AbsYTD VarYTD Var AbsYTD Var Abs I expect to be
156-11-111=1
26511002 =(1+1)
348-44-446 =(1+1+4 )
4101000-446 =(1+1+4+0)
59811-337 =(1+1+4+0+1)
6       
7       
8       
9       
10       
11       
12       
gooranga1
Power Participant
Power Participant

Not entirely sure about this as I haven't actually replicated it but have you tried changing your "Var abs" measure to something like 

 

=(Actual-Fcst)*if( (Actual-Fcst) <0,-1,1)

 

?

Unfortunately, it is not working either. For example, I want to calculate YTD ( Jan to Mar ). The correct answer is

 

Abs( Actual1 - Fcst1)  + Abs (Actual 2 - Fcst 2 ) + Abs(Actual 3 - Fcst3)  

 

But it results in the followng incorrect answer:

 

Abs [  (Actual1 +Actual2 + Actual 3)   -   (Fcst1+Fcst2+Fcst3)  ]

 

Any thoughts ?  Thanks.

 

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.