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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Manionpower
New Member

Reference different tables based on date

Hi Everyone,

 

I have a situation. I have a bunch of invoices which go through a series of approvals from different guys. So, naturally, i made a lookup tabel for the approval process. Now, some guys from the process left the company, and now new guys will replace them in the process. I want my report to show the names of ex-approvers before date dd-mm-yyy and name of new guys after that date. How can this be done?

 

Sample of my lookup table 

Manionpower_0-1732788371295.png

So just imagine guy 16 and guy 17 being replaced by Guy 20 and Guy 21 on date dd-mm-yyy. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the concern from danextian.

 

Hi @Manionpower ,

 

Based on your problem description I created simple data:

 

vlinhuizhmsft_0-1733194056952.png

vlinhuizhmsft_1-1733194066482.png

Merge the two tables.

vlinhuizhmsft_2-1733194140907.png

The relationship is shown in the figure:

vlinhuizhmsft_3-1733194173626.png

Create measure:

BeforeDateResponsible = 
CALCULATE(
    CONCATENATEX(
        VALUES('Table'[responsible person]),
       'Table'[responsible person],
        ", ",
        'Table'[responsible person],
        ASC
    ),
    FILTER(
        'Table',
        'Table'[Date of approval] <= MAX('Date'[Date])
    )
)
AfterDateResponsible = 
CALCULATE(
    CONCATENATEX(
        VALUES('Table'[responsible person]),
        'Table'[responsible person],
        ", ",
        'Table'[responsible person],
        ASC
    ),
    FILTER(
        'Table',
        'Table'[Date of approval] > MAX('Date'[Date])
    )
)

Combined these two measures and added logic: no duplicate display if there is no change in personnel:

CombinedResponsible = 
VAR _beforeDateResponsible = 
    CALCULATE(
        CONCATENATEX(
            VALUES('Table'[responsible person]),
            'Table'[responsible person],
            ", ",
            'Table'[responsible person],
            ASC
        ),
        FILTER(
            'Table',
            'Table'[Date of approval] <= MAX('Date'[Date])
        )
    )
VAR _aftertable = CALCULATETABLE(
    SELECTCOLUMNS(
        FILTER(
            'Table',
            'Table'[Date of approval] > MAX('Date'[Date])
        ),
        'Table'[responsible person]
    )
)
VAR _beforetable = CALCULATETABLE(
    SELECTCOLUMNS(
        FILTER(
            'Table',
            'Table'[Date of approval] <= MAX('Date'[Date])
        ),
        'Table'[responsible person]
    )
)
VAR _except = EXCEPT(_aftertable, _beforetable)
VAR _afterDateResponsible = 
    CALCULATE(
        CONCATENATEX(
            VALUES('Table'[responsible person]),
            'Table'[responsible person],
            ", ",
            'Table'[responsible person],
            ASC
        ),
        'Table'[responsible person] IN _except
    )
RETURN IF(_afterDateResponsible<>BLANK(),_beforeDateResponsible & "&" & _afterDateResponsible,_beforeDateResponsible)

Result:

vlinhuizhmsft_4-1733194423786.png

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks for the concern from danextian.

 

Hi @Manionpower ,

 

Based on your problem description I created simple data:

 

vlinhuizhmsft_0-1733194056952.png

vlinhuizhmsft_1-1733194066482.png

Merge the two tables.

vlinhuizhmsft_2-1733194140907.png

The relationship is shown in the figure:

vlinhuizhmsft_3-1733194173626.png

Create measure:

BeforeDateResponsible = 
CALCULATE(
    CONCATENATEX(
        VALUES('Table'[responsible person]),
       'Table'[responsible person],
        ", ",
        'Table'[responsible person],
        ASC
    ),
    FILTER(
        'Table',
        'Table'[Date of approval] <= MAX('Date'[Date])
    )
)
AfterDateResponsible = 
CALCULATE(
    CONCATENATEX(
        VALUES('Table'[responsible person]),
        'Table'[responsible person],
        ", ",
        'Table'[responsible person],
        ASC
    ),
    FILTER(
        'Table',
        'Table'[Date of approval] > MAX('Date'[Date])
    )
)

Combined these two measures and added logic: no duplicate display if there is no change in personnel:

CombinedResponsible = 
VAR _beforeDateResponsible = 
    CALCULATE(
        CONCATENATEX(
            VALUES('Table'[responsible person]),
            'Table'[responsible person],
            ", ",
            'Table'[responsible person],
            ASC
        ),
        FILTER(
            'Table',
            'Table'[Date of approval] <= MAX('Date'[Date])
        )
    )
VAR _aftertable = CALCULATETABLE(
    SELECTCOLUMNS(
        FILTER(
            'Table',
            'Table'[Date of approval] > MAX('Date'[Date])
        ),
        'Table'[responsible person]
    )
)
VAR _beforetable = CALCULATETABLE(
    SELECTCOLUMNS(
        FILTER(
            'Table',
            'Table'[Date of approval] <= MAX('Date'[Date])
        ),
        'Table'[responsible person]
    )
)
VAR _except = EXCEPT(_aftertable, _beforetable)
VAR _afterDateResponsible = 
    CALCULATE(
        CONCATENATEX(
            VALUES('Table'[responsible person]),
            'Table'[responsible person],
            ", ",
            'Table'[responsible person],
            ASC
        ),
        'Table'[responsible person] IN _except
    )
RETURN IF(_afterDateResponsible<>BLANK(),_beforeDateResponsible & "&" & _afterDateResponsible,_beforeDateResponsible)

Result:

vlinhuizhmsft_4-1733194423786.png

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

danextian
Super User
Super User

Hi @Manionpower 

This is most likely possible but no enough data to test. So you have those responsible guys when will their responsibility start and how do you intend to visualize or add this to your data? Please post a workable sample data  (not an image) and your expected result from that.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors