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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Dynamic Date parameter passed to Data source

<PBI noob here> Please help! 
Requirement: 

Need only Direct Query 

I should have the ability to select a single date from a slicer / calendar type of visual in the report 

This should be passed to the datasource and give me only the relevant rows. 

 

The datasource table/view doesnt have a single date field instead it has  2 columns "Start Date" and "End Date". Condition that needs to be applied is -- the selected date should fall between these two dates. 

 

Example: 

 

My table in the datasource 

Start DateEnd Date X
1/1/20221/3/2022A
1/2/20221/4/2022B
1/3/20221/5/2022C
1/4/20221/15/2022D

1/2/2022

1/13/2022E
1/5/20221/7/2022F
1/7/20221/22/2022G
1/8/20221/9/2022H

 

My selection in the PowerBI report (slicer )(Direct Query mode) 

Selected Date: 1/6/2022

Result in the PowerBI report visual

 

Start DateEnd DateX
1/4/20221/15/2022D

1/2/2022

1/13/2022E
1/5/20221/7/2022F

 

How can I achieve this ? @amitchandak @Greg_Deckler @Jihwan_Kim @d_gosbell @tamerj1 @lbendlin 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_1-1665630821333.png

 

 

Jihwan_Kim_0-1665630800173.png

 

 

expected result measure: = 
IF (
    HASONEVALUE ( Data[Start Date] ),
    MAXX (
        FILTER (
            Data,
            Data[End Date] >= MIN ( 'Calendar'[Date] )
                && Data[Start Date] <= MAX ( 'Calendar'[Date] )
        ),
        Data[X]
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

3 REPLIES 3
tamerj1
Community Champion
Community Champion

Hi @Anonymous 

please place the following measure in the filter pane on the table visual and select 'is not blank' then apply the filter 

Filter Measure =
COUNTROWS (
    FILTER (
        'Table',
        'Table'[StartDate] <= SELECTEDVALUE ( 'Calendar'[Date] )
            && 'Table'[EndDate] >= SELECTEDVALUE ( 'Calendar'[Date] )
    )
)
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_1-1665630821333.png

 

 

Jihwan_Kim_0-1665630800173.png

 

 

expected result measure: = 
IF (
    HASONEVALUE ( Data[Start Date] ),
    MAXX (
        FILTER (
            Data,
            Data[End Date] >= MIN ( 'Calendar'[Date] )
                && Data[Start Date] <= MAX ( 'Calendar'[Date] )
        ),
        Data[X]
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

amitchandak
Super User
Super User

@Anonymous , if you create a measure and use that in visual or visual level filter

 

var _max = maxx(allselected(Date), Date[Date])

return

countx(Filter(Table, Table[Start Date] <= _max  && Table[End Date] >=_max), [X])

 

or explore Dynamic M parameter

https://blog.crossjoin.co.uk/2020/10/25/why-im-excited-about-dynamic-m-parameters-in-power-bi/

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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.