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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
yodha
Helper IV
Helper IV

DAX for Text box

i have start date field in my data like this,

 

Capture.PNG

 

i am using a slicer for start date in my report like this, Untitled.png

 

and i have a text box for duration in my report like this Untitled1.png

 

if i select a start date using "startdate slicer" and enter days in "Duration" text box, the start date in the table should change accordingly.

For example my start date is "1/7/19" and duration is "2 days", the data in the table should change like this, 

Capture.PNG

How to achieve this functionality in power bi? any help on this is much appreciated, thanks in advance.

4 REPLIES 4
Anonymous
Not applicable

Well, all your measures must be aware of the selection in the slicer(s) and return BLANK for the days that are outside of the defined period. If they do, then the column below such an out-of-period date will store BLANKs only and in effect, the column will not be shown.

 

Best

Darek

Hi,

but how to do this, can you please provide an example.

 

thanks in advance.

Anonymous
Not applicable

-- Let A be any measure in the model.
-- Then let B be the version that you're
-- after.

B =
var __dayVisibleInSlicer =
	SELECTEDVALUE( DaySlicer[Day] )
var __numOfDaysVisibleInSlicer =
	SELECTEDVALUE( NumOfDaysSlicer[Number of Days] )
var __startDate = __dayVisibleInSlicer
var __endDate =
	__dayVisibleInSlicer
	+ __numOfDaysVisibleInSlicer
	- 1
var __dayVisibleInCurrentContext =
	SELECTEDVALUE( 'Calendar'[Date] )
var __dayVisibleInCurrentContextIsBetweenBounds =
	__startDate <= __dayVisibleInCurrentContext
	&& __dayVisibleInCurrentContext <= __endDate
var __b =
	if(
		__dayVisibleInCurrentContextIsBetweenBounds,
		[A]
	)
return
	__b

Best

Darek

Hi,

thanks for the reply

i have  tried this but it is not working for me.

sharing the PBIX file pbix file. can u please check it?

thank you.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.