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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
nathass
Regular Visitor

Filter table based on date ranger slicer

I have a transaction table with several date columns and also a date dimension table defined in Power BI.

For example, the transaction table contains Order, Customer, Country, OrderStart,OrderEnd,ShipmentStart,ShipmentEnd,DeliveryStart,DeliveryEnd. What I want is to show only those records with Order, Customer, Country information in a table visual where all of these dates falls within a chosen date. The chosen date should be from a Slicer which I have it built from the Date dimension table. 

 

I tried this approach of creating a measure and placing this on visual level filters but doesnt give me all records in the output. How can this situation be handled efficiently.

IsValid =
var sDate = max('01. Dim_Date'[Date])
var order_from = SELECTEDVALUE('04. Fact_RO_Contract'[OrderStart])
var order_to = SELECTEDVALUE('04. Fact_RO_Contract'[OrderEnd])
var delivery_from = SELECTEDVALUE('04. Fact_RO_Contract'[DeliveryStart])
var delivery_to = SELECTEDVALUE('04. Fact_RO_Contract'[DeliveryEnd])
RETURN IF(order_from <= sDate &&order_to >= sDate && delivery_from <= sDate && delivery_to >= sDate, 1,0)
1 ACCEPTED SOLUTION
v-saisrao-msft
Community Support
Community Support

Hi @nathass, 
Thank you for reaching out to the Microsoft fabric community forum. Thank you @bhanu_gautam, for your input on this issue. 

After thoroughly reviewing the details you provided, I was able to reproduce the scenario, I have used it as sample data on my end and successfully implemented it.   

Dax Measure: 

IsWithinSelectedRange = 
VAR SelectedStart = MIN('01. Dim_Date'[Date])
VAR SelectedEnd   = MAX('01. Dim_Date'[Date])
RETURN
IF (
    MIN(Fact_RO_Contract'[OrderStart]) >= SelectedStart &&
    MAX(Fact_RO_Contract'[OrderEnd])   <= SelectedEnd &&
    MIN(Fact_RO_Contract'[DeliveryStart]) >= SelectedStart &&
    MAX(Fact_RO_Contract'[DeliveryEnd])   <= SelectedEnd &&
    MIN(Fact_RO_Contract'[ShipmentStart]) >= SelectedStart &&
    MAX(Fact_RO_Contract'[ShipmentEnd])   <= SelectedEnd,
    1,
    0
)

Output: 

vsaisraomsft_0-1748413353880.png

If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly. 
 
Thank you. 

View solution in original post

5 REPLIES 5
v-saisrao-msft
Community Support
Community Support

Hi @nathass, 
Thank you for reaching out to the Microsoft fabric community forum. Thank you @bhanu_gautam, for your input on this issue. 

After thoroughly reviewing the details you provided, I was able to reproduce the scenario, I have used it as sample data on my end and successfully implemented it.   

Dax Measure: 

IsWithinSelectedRange = 
VAR SelectedStart = MIN('01. Dim_Date'[Date])
VAR SelectedEnd   = MAX('01. Dim_Date'[Date])
RETURN
IF (
    MIN(Fact_RO_Contract'[OrderStart]) >= SelectedStart &&
    MAX(Fact_RO_Contract'[OrderEnd])   <= SelectedEnd &&
    MIN(Fact_RO_Contract'[DeliveryStart]) >= SelectedStart &&
    MAX(Fact_RO_Contract'[DeliveryEnd])   <= SelectedEnd &&
    MIN(Fact_RO_Contract'[ShipmentStart]) >= SelectedStart &&
    MAX(Fact_RO_Contract'[ShipmentEnd])   <= SelectedEnd,
    1,
    0
)

Output: 

vsaisraomsft_0-1748413353880.png

If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly. 
 
Thank you. 

Thanks, mind explaining why this works and not when using SELECTEDVALUE?

nathass
Regular Visitor

The above works if I have the date fields on the table visual but I do not want to have those date fields on the visual. Is there a way around?

Ashish_Excel
Super User
Super User

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.

bhanu_gautam
Super User
Super User

@nathass Make sure all date columns in your transaction table and the date column in your date dimension table are of the same data type (Date).

 

Then create measure

DAX
IsValid =
VAR sDate = MAX('01. Dim_Date'[Date])
VAR order_from = SELECTEDVALUE('04. Fact_RO_Contract'[OrderStart])
VAR order_to = SELECTEDVALUE('04. Fact_RO_Contract'[OrderEnd])
VAR shipment_from = SELECTEDVALUE('04. Fact_RO_Contract'[ShipmentStart])
VAR shipment_to = SELECTEDVALUE('04. Fact_RO_Contract'[ShipmentEnd])
VAR delivery_from = SELECTEDVALUE('04. Fact_RO_Contract'[DeliveryStart])
VAR delivery_to = SELECTEDVALUE('04. Fact_RO_Contract'[DeliveryEnd])
RETURN IF(
order_from <= sDate && order_to >= sDate &&
shipment_from <= sDate && shipment_to >= sDate &&
delivery_from <= sDate && delivery_to >= sDate,
1,
0
)

 

Use this measure as a visual-level filter in your table visual. Set the filter to show records where IsValid equals 1.

Ensure that there is a proper relationship between your transaction table and the date dimension table. This relationship is crucial for the slicer to filter the data correctly.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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