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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
plukacsi
Helper I
Helper I

SUMX with YTD calculation gerenates zero in TOTAL

Hi,

I am using the M2 YTD measure and it simply generates zero in Total while single filtered rows are perfect.

If I embed M2 in a CALCULATE then Total will be an irrationally big number.

 

Thank you for your help in advance!

 

BR,

Peter

 

M1= sumx('fYFSP03T_BS 2',
IF( IFERROR(find(right(RELATED(dCustomer_API[RBCustomerID]),4),max('fYFSP03T_BS 2'[R_U_L_E_S])),0) <> 0,'fYFSP03T_BS 2'[Corrected_Value]))

 

M2 = sumx(filter(ALL(DimDate[Date_]),DimDate[Date_]<=max(DimDate[Date_]) && year(DimDate[Date_]) = YEAR(MAX((DimDate[Date_])))), M1 )

6 REPLIES 6
v-lili6-msft
Community Support
Community Support

hi @plukacsi 

Try to add a CALCULATE  in M1 as below:

M1=CALCULATE( sumx('fYFSP03T_BS 2',
IF( IFERROR(find(right(RELATED(dCustomer_API[RBCustomerID]),4),max('fYFSP03T_BS 2'[R_U_L_E_S])),0) <> 0,'fYFSP03T_BS 2'[Corrected_Value])) )

 

If you still have the problem, please share your sample pbix file for us have a test.

 

Regards,

Lin

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

Hi,

 

What I have just realized that only P1 total is missing in M1  P2-P12 M1  is totally okey, but because of the 0 P1 YTDP2-P12 is wrong.

 

M1=CALCULATE( sumx('fYFSP03T_BS 2',
IF( IFERROR(find(right(RELATED(dCustomer_API[RBCustomerID]),4),max('fYFSP03T_BS 2'[R_U_L_E_S])),0) <> 0,'fYFSP03T_BS 2'[Value])) )

 

P.S.: with an other simple M1 SUM measure wo. any SUMX and filter I can see the missing element in the total line. 

 

Thank you for your help!

 

BR,

Peter

Hi,

 

thank you, now I have a figure in total row, but unfortunately a disconnected and extreme big number.

 

This is a big AAS model, so Desktop version not really available.

 

Thank you for your further help in advance!

Peter

 

amitchandak
Super User
Super User

Try using datesytd, totalytd

example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"3/31"))

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"3/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"3/31"))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi


https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amit,

 

Thank you, but all built-in YTD function brings mi zero in total row.

 

BR,

Peter

Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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