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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Rbie
Frequent Visitor

Using 1 slicer to get all the correct dates

I have the following 3 tables in my model , table 1 has a one to many relation to table 2 and 3 via EmplID

EmplIDEmployedFromEmployedTo 
11/01/201931/12/2054 
    
EmplIDReportToFromReportsToToReportsToID
11/01/201931/12/20191
11/01/202031/12/20203
11/01/202131/12/20544
    
EmplIDPositionFromPositionToPositionID
11/01/201930/06/201912
11/07/201930/06/202113
11/07/202131/12/205414

 

What I'm trying to achieve via 1 slicer is to get the correct record out of each table. So for instance if I would choose the date 

1/1/2020

The report  would show 

EmplIDReportstoPosition
1313

1/1/2021 would result in

EmplIDReportstoPosition
14

13

 

How can this be achived ?

Thanks in advance ,

Rbie

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @Rbie ,

 

Please try to add a Date table and create measure with below dax formula:

Date:

vbinbinyumsft_0-1701395912920.png

 

EmpID =
VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _b =
    CALCULATE (
        MAX ( 'Table 1'[EmplID] ),
        FILTER ( ALL ( 'Table 1' ), [EmployedFrom] <= _a && [EmployedTo] >= _a )
    )
RETURN
    _b
Reports To =
VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _b =
    CALCULATE (
        MAX ( 'Table 2'[ReportsToID] ),
        FILTER ( ALL ( 'Table 2' ), [ReportToFrom] <= _a && [ReportsToTo] >= _a )
    )
RETURN
    _b
Position =
VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _b =
    CALCULATE (
        MAX ( 'Table 3'[PositionID] ),
        FILTER ( ALL ( 'Table 3' ), [PositionFrom] <= _a && [PositionTo] >= _a )
    )
RETURN
    _b

Add a slicer with Date table, add a table visual with measure:

Animation36.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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

1 REPLY 1
v-binbinyu-msft
Community Support
Community Support

Hi @Rbie ,

 

Please try to add a Date table and create measure with below dax formula:

Date:

vbinbinyumsft_0-1701395912920.png

 

EmpID =
VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _b =
    CALCULATE (
        MAX ( 'Table 1'[EmplID] ),
        FILTER ( ALL ( 'Table 1' ), [EmployedFrom] <= _a && [EmployedTo] >= _a )
    )
RETURN
    _b
Reports To =
VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _b =
    CALCULATE (
        MAX ( 'Table 2'[ReportsToID] ),
        FILTER ( ALL ( 'Table 2' ), [ReportToFrom] <= _a && [ReportsToTo] >= _a )
    )
RETURN
    _b
Position =
VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _b =
    CALCULATE (
        MAX ( 'Table 3'[PositionID] ),
        FILTER ( ALL ( 'Table 3' ), [PositionFrom] <= _a && [PositionTo] >= _a )
    )
RETURN
    _b

Add a slicer with Date table, add a table visual with measure:

Animation36.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.