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
AnandNamburi
Helper III
Helper III

Current year calculation not yielding proper results when I'm are displaying along date hierarchy

Hi All,

To display CY I have written below DAX, it is working fibe when I'm displaying it alone.

CY Sales = CALCULATE(SUM(Orders[Sales]),FILTER(ALLSELECTED(Orders),Orders[Order Date].[Year]=MAX(Orders[Order Date].[Year])))
 
 
 
 

Capture.PNG

But when I'm bring the year column alsong with it, the data is getting group by Year column. Please see below.

Capture1.PNG

I need to display only CY along with 2013, which is not happening in above visualization.

I believe in my DAX calculation I'm using [Year] and thts' why I'm not able to acheive this.

 

Can anyone fine tune my DAX to get the accurate results along with Year,Quarter,Month.

 

Thanks,

Anand

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@AnandNamburi , Try like

 

CY Sales =
var _max = MAXX(allselected(Orders) , Orders[Order Date].[Year])
return
CALCULATE(SUM(Orders[Sales]),FILTER(ALLSELECTED(Orders),Orders[Order Date].[Year]=_max))

 

But prefer to use time intelligence

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@AnandNamburi , Try like

 

CY Sales =
var _max = MAXX(allselected(Orders) , Orders[Order Date].[Year])
return
CALCULATE(SUM(Orders[Sales]),FILTER(ALLSELECTED(Orders),Orders[Order Date].[Year]=_max))

 

But prefer to use time intelligence

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

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.