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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Sam7
Advocate II
Advocate II

Switch between two date options based on Filter

I have read many different versions of this question, this one here nearly gets what I want: https://community.powerbi.com/t5/Desktop/Filter-records-between-two-date-columns-with-one-slicer/m-p...

 

I want to create a filter based on two options shipped date and order date

If the user selects shipped date, I want all the results based on sshipped date, if the user selects order date then I want the results based on this date. How do I do this? 

 

I have read a lot, but can't find this?  Please help

1 ACCEPTED SOLUTION

Hi @Sam7 ,

I updated my sample pbix file(see attachment), please check whether that is what you want.

1. Create a date type dimension table by Enter data method

yingyinr_1-1654765168052.png

2. Create a date dimension table and apply the date field on the slicer

Date = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))

3. Update the formula of measure [qty] and [ssales]

yingyinr_0-1654765093648.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-yiruan-msft
Community Support
Community Support

Hi @Sam7 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create two date dimension table base on the fact table

Note: Do not create any relationship between these two date dimension tables and fact table

yingyinr_1-1654741210495.png

2. Apply the date field in above tables on the slicers

yingyinr_2-1654741231232.png

3. Create the measures to get the values during the selected date periods

qty = 
CALCULATE (
    SUM ( 'Table'[quantity] ),
    FILTER (
        'Table',
        IF (
            ISFILTERED ( 'Shipped date'[date] ),
            'Table'[shipped date] >= MIN ( 'Shipped date'[Date] )
                && 'Table'[shipped date] <= MAX ( 'Shipped date'[Date] ),
            1 = 1
        )
            && IF (
                ISFILTERED ( 'Order date'[Date] ),
                'Table'[order date] >= MIN ( 'Order date'[Date] )
                    && 'Table'[order date] <= MAX ( 'Order date'[Date] ),
                1 = 1
            )
    )
)

yingyinr_0-1654741170705.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks

 

How do I build this with an option to choose the date tyoe and only one date slicer?

 

 

Hi @Sam7 ,

I updated my sample pbix file(see attachment), please check whether that is what you want.

1. Create a date type dimension table by Enter data method

yingyinr_1-1654765168052.png

2. Create a date dimension table and apply the date field on the slicer

Date = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))

3. Update the formula of measure [qty] and [ssales]

yingyinr_0-1654765093648.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

After much internet sluething, this is the one that finally solved the issue for me. Of course in my use-case, I didn't need to show the summed column so I just put it in a visual filter and said give me rows that are "not blank"

Sam7
Advocate II
Advocate II

 This didn't work as I want the fields to have a slicer, and then the actual date to be the next filter selected. How do I this?

 

Sam7_0-1654682021692.png

Thanks

Sam7
Advocate II
Advocate II

I'll give this a go, thanks for your help.

amitchandak
Super User
Super User

@Sam7 , You can create an active inactive relationship and create two measure and switch those using measure slicer

 

example

Order =calculate( SUM(Sales[Sales Amount]),USERELATIONSHIP ('Sales'[order date], 'Date'[Date])

 

Ship = calculate( SUM(Sales[Sales Amount]),USERELATIONSHIP ('Sales'[shipped Date], 'Date'[Date])

 

For measure slicer use field parameters

https://medium.com/@amitchandak/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9a...

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.