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
Anonymous55
Frequent Visitor

Filtering a DAX measure by a value in a separate table

Hi!

 

I have a table ('Emails') which records info about all emails received by my company. This table has a column ('Time taken') which records how many days my company took to respond to the email. I previously wanted to calculate the percentage of emails which were responded to within 2 days. I used the following DAX, which worked great:

 

Value =

CALCULATE(

COUNTROWS('Emails') 'Emails'[Time taken] <= 2

) / COUNTROWS(Emails)

 

I now need to calculate the percentage of emails which were responded to within 2 *working* days. I have a separate table ('Dates') which has a column ('Working or non-working') that records whether a day is classed as a working or non-working day. A many-to-one relationship exists between 'Emails'[Date] and 'Dates'[Date].  Can anyone help me adjust the DAX above to achieve this?

 

For what it's worth, the 'Time Taken' column is a custom column which I created in Power Query. It's just a Date.Difference formula which calculates the days between two dates - maybe I need to tweak something here first?

 

I have tried a few things already with the help of ChatGPT which have either produced the following error message: 'The column 'Dates[Working or non-working]' either doesn't exist or doesn't have a relationship to any table available in the current context'; or given me 100%, which is incorrect. 

 

Thank you and please let me know if you need more info!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous55 ,

Please try this DAX:

WorkingDaysCount = 
CALCULATE(
    COUNTROWS('Dates'),
    'Dates'[Working or non-working] = "Working",
    DATESBETWEEN('Dates'[Date], 'Emails'[ReceivedDate], 'Emails'[RespondedDate])
)
RespondedWithin2WorkingDays = 
CALCULATE(
    COUNTROWS('Emails'),
    [WorkingDaysCount] <= 2
)
PercentageRespondedWithin2WorkingDays = 
DIVIDE(
    [RespondedWithin2WorkingDays],
    COUNTROWS('Emails'),
    0
)

If this not works, can you provide some sample data?

Best Regards,
Dino Tao
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
Anonymous
Not applicable

Hi @Anonymous55 ,

Please try this DAX:

WorkingDaysCount = 
CALCULATE(
    COUNTROWS('Dates'),
    'Dates'[Working or non-working] = "Working",
    DATESBETWEEN('Dates'[Date], 'Emails'[ReceivedDate], 'Emails'[RespondedDate])
)
RespondedWithin2WorkingDays = 
CALCULATE(
    COUNTROWS('Emails'),
    [WorkingDaysCount] <= 2
)
PercentageRespondedWithin2WorkingDays = 
DIVIDE(
    [RespondedWithin2WorkingDays],
    COUNTROWS('Emails'),
    0
)

If this not works, can you provide some sample data?

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

DataInsights
Super User
Super User

@Anonymous55,

 

One option is to move your Time taken column from Power Query to DAX, using this calculated column in table Emails:

 

Time taken = 
VAR vReceivedDate = Emails[Received Date]
VAR vRespondedDate = Emails[Responded Date]
VAR vDaysBetween =
    DATEDIFF ( vReceivedDate, vRespondedDate, DAY )
VAR vNonWorkingDays =
    COUNTROWS (
        CALCULATETABLE (
            Dates,
            Dates[Date] >= vReceivedDate,
            Dates[Date] <= vRespondedDate,
            Dates[Working or non-working] = "Non-working"
        )
    )
VAR vResult = vDaysBetween - vNonWorkingDays
RETURN
    vResult

 

In this example, there is no relationship between the tables. Your measure should work with this column.





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

Proud to be a Super User!




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