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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

DAX YTD problem

Hello guys!

I am new to Power BI and I need some help.

YTD calculation stops working correctly when I add  Date column not from the Date Hierarchy.

This is my DAX formula:

Actual YTD 2 = CALCULATE(TotalYTD(SUMX('Fact',(IF('Fact'[Scenario ID]=1,'Fact'[Value]*0.3,0))),'Date'[Date]))
 
It gives correct result when I show in the Table only Actual YTD 2, 'Date'[Date] and other dimension, for example:
allosewa_0-1659970010880.png

But when I add Date field from another linked table, it works incorrectly, treats new column as a dimension and the number of rows is multiplied:

allosewa_1-1659970096578.png

Joins between tables are configured correctly the problem is in calculation as I think. Could you maybe help how to solve it?

I want to ınclude ın my Vız date from the 'Fact' table, not from the separate Date hierarchy.

 

 https://app.powerbi.com/groups/me/reports/38338827-c863-4516-a1ab-bf4e5a0fd6c6?ctid=b41b72d0-4e9f-4c...

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , try like the example. The two comments at end are alternate

 

YTD QTY forced= 
var _max = //or maxx(allselected('Order'),'order'[Date]) //max date in table
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks!

daXtreme
Solution Sage
Solution Sage

@Anonymous 

 

The rules of correct PBI model design dictate that:

1. You should hide your fact table's columns.

2. You should only slice by dimensions. I can't stress this enough.

3. Your model should be a star-schema.

 

If you stick to these golden rules, you won't have problems.

amitchandak
Super User
Super User

@Anonymous , try like the example. The two comments at end are alternate

 

YTD QTY forced= 
var _max = //or maxx(allselected('Order'),'order'[Date]) //max date in table
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

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

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.