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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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