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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AJBI
Frequent Visitor

Filter a dataset based on another table Date rage

AJBI_0-1667135759698.png

i have the following offers table each offer has a start and an end date.

i have another dataset containing data about contracts each contract has a creation date

 

how can I make a dynamic slicer that filters the contracts data between the offer start and end date without connecting the two tables based on the offer name? 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @AJBI ,

 

Try formula like below:

M =
VAR sel_ =
    SELECTEDVALUE ( 'Table'[OfferName] )
VAR start_sel =
    CALCULATE ( MAX ( 'Table'[OfferStart] ), sel_ = 'Table'[OfferName] )
VAR end_sel =
    CALCULATE ( MAX ( 'Table'[OfferEnd] ), sel_ = 'Table'[OfferName] )
RETURN
    CALCULATE (
        SUM ( Data[Value] ),
        Data[OfferName] = sel_
            && MAX ( Data[Date] ) <= end_sel
            && MAX ( Data[Date] ) >= start_sel
    )

 

If the problem is still not resolved, please provide test data and expected result screenshoots. Looking forward to your reply.


Best Regards,
Henry


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

2 REPLIES 2
AJBI
Frequent Visitor

Hi Thank you for your response,

I have a question about how to apply the filtering.

the measure you wrote retrieves the total value of the contracts and when i try to apply slicers or filters from the second table based on the offer name nothing happens? 

here is a sample of my data

Contracts Table 

IdCreationsDateContractValue
101/02/2022100$
203/03/2022250$
324/03/2022364$
401/02/2022255$
529/03/2022100$
624/03/2022250$
701/07/2022364$
803/05/2022255$
924/06/2022100$

OfferTable

OfferNameOfferstartOfferEnd
offer101/01/202202/02/2022
Offer203/07/202206/05/2022
Offer302/01/202307/08/2022
offer404/07/202308/11/2022
offer503/01/202409/02/2023
offer604/07/202413/05/2023
offer703/01/202514/08/2023

 

i want to know how to filter contracts based on offer start and end date.

thank you

v-henryk-mstf
Community Support
Community Support

Hi @AJBI ,

 

Try formula like below:

M =
VAR sel_ =
    SELECTEDVALUE ( 'Table'[OfferName] )
VAR start_sel =
    CALCULATE ( MAX ( 'Table'[OfferStart] ), sel_ = 'Table'[OfferName] )
VAR end_sel =
    CALCULATE ( MAX ( 'Table'[OfferEnd] ), sel_ = 'Table'[OfferName] )
RETURN
    CALCULATE (
        SUM ( Data[Value] ),
        Data[OfferName] = sel_
            && MAX ( Data[Date] ) <= end_sel
            && MAX ( Data[Date] ) >= start_sel
    )

 

If the problem is still not resolved, please provide test data and expected result screenshoots. Looking forward to your reply.


Best Regards,
Henry


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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