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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
PRay
Frequent Visitor

Dax syntax for YTD change & % change for measure in same year

I have the monthly change and monthly change %, but I cannot figure out how to get the measures for YTD change and YTD % in green below.  Please see data below.

 

Tables

field

AsofDate

as of date

pptsCounts

Med All

 

 

Measures

Medical TY = sum(PPTCounts[Med All])

Medical LM = CALCULATE(PPTCounts[Medical TY], PREVIOUSMONTH(AsofDate[As of Date]))

 

Medical MTH Delta = Medical MTH Delta = [Medical TY] - [Medical LM]

Mth % change = Divide([Medical TY], [Medical LM], blank())-1

 

PRay_1-1620751086137.png

 

 

3 REPLIES 3
PRay
Frequent Visitor

@amitchandak , could you please take another look at this?

amitchandak
Super User
Super User

@PRay , Are your YTD formula correct?

 

I was expecting

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

 

to have color you can use conditional formatting like

Color measure =

Switch( True() ,

[diff] >0 , "green" ,

"Red"

)

 

And you can use this in conditional formatting with field value option

 

Color Field - Color Measure - Conditional formatting
https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values
https://www.youtube.com/watch?v=RqBb5eBf_I4

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, thanks for taking a look at this.. I need the dax syntax to get ytd growth and ytd % growth for Med All.  The info above was just a mock up from Excel, which is not my source data.  I need to do this in dax similar to how you showed me how to get the month to month growth and % growth in this request


https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dax-Calculate-difference-between-2-values-in-...

 

thx

 

 

Helpful resources

Announcements
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!

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.