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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
tomcch
Frequent Visitor

Build Relationship with Multiple Date Field (Larger and Smaller Than)

Hello all,

 

The main table is Sales Volume Table, I would like to join it to the Sales Incentive Table to get the STAFF name by joining 1) Customer Column (this one is simple), 2) the [SALES VOLUME TABLE.DATE] Larger than [SALES INCENTIVE TABLE.FROM DATE] and 3)the [SALES VOLUME TABLE.DATE] Smaller than [SALES INCENTIVE TABLE.TO DATE].

 

In the below case, only the first three records of the sales volume table should show Peter as a result becasue the last record's date is September 2023 which is not within the FROM DATE and TO DATE of the Sales Incentive table.

 

Is it something we could do in the power bi?

Thank you so much.

 

SALES VOLUME TABLE

CUSTOMERDATE
A2023-01-02
A2023-01-21
A2023-01-02
A2023-09-02

 

SALES INCENTIVE TABLE

CUSTOMERSTAFFFROM DATETO DATE
APETER2023-01-012023-03-01
BTOM2023-01-012023-03-01
CDAVID2023-03-012023-06-01
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @tomcch ,

You can create a calculated column as below in the table 'Sales Volume' to get it, please find the details in the attachment.

Column = 
CALCULATE (
    MAX ( 'Sales Incentive'[STAFF] ),
    FILTER (
        'Sales Incentive',
        'Sales Incentive'[CUSTOMER] = 'Sales Volume'[CUSTOMER]
            && 'Sales Volume'[DATE] > 'Sales Incentive'[FROM DATE]
            && 'Sales Volume'[DATE] < 'Sales Incentive'[TO DATE]
    )
)

vyiruanmsft_0-1699253861960.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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @tomcch ,

You can create a calculated column as below in the table 'Sales Volume' to get it, please find the details in the attachment.

Column = 
CALCULATE (
    MAX ( 'Sales Incentive'[STAFF] ),
    FILTER (
        'Sales Incentive',
        'Sales Incentive'[CUSTOMER] = 'Sales Volume'[CUSTOMER]
            && 'Sales Volume'[DATE] > 'Sales Incentive'[FROM DATE]
            && 'Sales Volume'[DATE] < 'Sales Incentive'[TO DATE]
    )
)

vyiruanmsft_0-1699253861960.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.
Arpitb12
Helper I
Helper I

Connect and load your "Sales Volume Table" and "Sales Incentive Table."
Create a relationship between these tables using the "CUSTOMER" column.
Use DAX to filter the "Sales Volume Table" based on date ranges in the "Sales Incentive Table."
Build a visualization with the "STAFF" column to display staff names for filtered sales data.

Thank you.

I'm a beginner of PBI, which DAX function should I use?

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

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.