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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shareezsaleem
Helper III
Helper III

Dynamic Dates Using SelectedValue

Hi Team,

 

I am using the below measure and it works fine, but I need to replace the date with the measures (Start Date & End Date) which I have created.

YTD= if(calculate(TOTALYTD(SUM('Transactions'[P&L Amount]),'Calendar'[Date]),'Transactions'[Revenue/Expense]<>"BS")=BLANK(),CALCULATE(SUM(Transactions[P&LAmount]),DATESBETWEEN('Calendar'[Date],"01/01/2022","04/30/2022"),Transactions[Revenue/Expense]>"BS"),calculate(TOTALYTD(SUM('Transactions'[P&LAmount]),'Calendar'[Date]),'Transactions'[Revenue/Expense]<>"BS"))

 

Start Date = DATEVALUE("01-01-"&SELECTEDVALUE('Calendar'[Year]))

 
End Date = datevalue(SELECTEDVALUE('Calendar'[Month])&"-"&DAY(EOMONTH(DATE(SELECTEDVALUE('Calendar'[Year]),SELECTEDVALUE('Calendar'[Month]),1),0))&"-"&SELECTEDVALUE('Calendar'[Year]))
1 ACCEPTED SOLUTION
shareezsaleem
Helper III
Helper III

Hi Amit,

 

I am calculating YTD but 2 of our business unit has no entries in last 2 months and thus YTD shows blank.

So I have used the above formula to replace the blanks. Now In my formula, I would like to replace the dates (in red font) with the slicer selections (Start and end dates dax measures is build based on that). When I tried to incorporate these 2 measures in YTD measure, it doesn't work.

Do you have a solution for this? Any new measure is acceptable.

 

 

View solution in original post

2 REPLIES 2
shareezsaleem
Helper III
Helper III

Hi Amit,

 

I am calculating YTD but 2 of our business unit has no entries in last 2 months and thus YTD shows blank.

So I have used the above formula to replace the blanks. Now In my formula, I would like to replace the dates (in red font) with the slicer selections (Start and end dates dax measures is build based on that). When I tried to incorporate these 2 measures in YTD measure, it doesn't work.

Do you have a solution for this? Any new measure is acceptable.

 

 

amitchandak
Super User
Super User

@shareezsaleem ,Not very clear what you need here

For YTD you can try like

 

YTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors