Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi all,
I have the following model which involves 2 fact tables and 2 dimension tables:
Fact Table A = table of enquiries with a date of enquiry and other related dates about the enquiry e.g. Date enquiry dealt with, date of next enquiry. Many enquiries relate to a single customer, who has one phone number. (named 'SQL_Enquiries')
Date of Enquiry | Phone Number | Min call date window | Max call date window | Contact Number | Enquiry Number |
15/01/2024 | 779124623 | 18/01/2024 | 123456 | 1 | |
16/01/2024 | 779124623 | 18/01/2024 | 24/01/2024 | 123456 | 2 |
17/01/2024 | 776634661 | 25/01/2024 | 818654 | 1 |
Fact Table B = table of phone calls which has a column for date of call and caller phone number (named 'Compiled Call Log')
Call Time | Phone Number |
14/01/2024 15:39:00 | 779124623 |
15/01/2024 08:30:00 | 779124623 |
21/01/2024 10:31:00 | 776634661 |
Dim Table A = date table which is linked via 2 1:many active relationships to A & B’s date of enquiry/call
Dim Table B = list of phone numbers also linked via 2 1:many active relationships to A & B via the phone number columns
Phone Number |
779124623 |
776634661 |
I have a couple of calculated columns in table A which evaluate the maximum call date and the minimum call date to establish a range of call dates that ‘could’ relate to a phone call to use as a filter.
I am looking to create a measure to evaluate the number of phone calls made related to each enquiry (via the phone number) filtered by whether the call date falls into the maximum / minimum range of the enquiry date.
I’ve managed to do this as a calculated column in table A with the following DAX, but I cannot get this to work as a measure - any help appreciated please!
Note - I could join fact table A and fact table B to go with a proper star schema but I don’t wish to filter all existing measures for enquiries based on whether they are an enquiry or a call.
Thanks!
Solved! Go to Solution.
To handle scenarios where there isn't a single value for the variables due to the iteration over rows in 'SQL_Enquiries', you can use the SUMX function along with FILTER to iterate over each row of 'SQL_Enquiries'. Within the iteration, you can calculate the count of related phone calls for each enquiry. Here's how you can modify the measure:
Phone Calls Related to Enquiries =
SUMX(
'SQL_Enquiries',
VAR CurrentEnquiry = 'SQL_Enquiries'[Enquiry Number]
RETURN
CALCULATE(
COUNTROWS('Compiled Call Log'),
FILTER(
'Compiled Call Log',
'Compiled Call Log'[Phone Number] = EARLIER('SQL_Enquiries'[Phone Number]) &&
'Compiled Call Log'[Call Time] >= EARLIER('SQL_Enquiries'[Min call date window]) &&
'Compiled Call Log'[Call Time] <= EARLIER('SQL_Enquiries'[Max call date window])
)
)
)
Explanation:
This modification should allow the measure to correctly evaluate the count of phone calls related to each enquiry, considering the date range conditions for each row in 'SQL_Enquiries'.
If I answered your question, please mark my post as solution, Appreciate your Kudos.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
To create a measure that evaluates the number of phone calls made related to each enquiry (via the phone number) filtered by whether the call date falls into the maximum/minimum range of the enquiry date, you can use DAX functions to calculate this dynamically. Here's how you can approach it:
Calls Related to Enquiries =
VAR EnquiryPhone = 'SQL_Enquiries'[Phone Number]
VAR MinCallDate = 'SQL_Enquiries'[Min call date window]
VAR MaxCallDate = 'SQL_Enquiries'[Max call date window]
RETURN
CALCULATE(
COUNTROWS('Compiled Call Log'),
'Compiled Call Log'[Phone Number] = EnquiryPhone,
'Compiled Call Log'[Call Time] >= MinCallDate,
'Compiled Call Log'[Call Time] <= MaxCallDate
)
Explanation:
You can create this measure in your model and use it in your reports to get the count of phone calls related to each enquiry based on the specified date range.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Hi, thanks for this! I understand the approach trying to be used here, but the measure won't work without there being a single value for the variables defined, I tried using SELECTEDVALUE() around the 3 variables but that doesn't seem to do the trick - is there another function I can try to get it evaluate each enquiry row in turn? Thanks!
To handle scenarios where there isn't a single value for the variables due to the iteration over rows in 'SQL_Enquiries', you can use the SUMX function along with FILTER to iterate over each row of 'SQL_Enquiries'. Within the iteration, you can calculate the count of related phone calls for each enquiry. Here's how you can modify the measure:
Phone Calls Related to Enquiries =
SUMX(
'SQL_Enquiries',
VAR CurrentEnquiry = 'SQL_Enquiries'[Enquiry Number]
RETURN
CALCULATE(
COUNTROWS('Compiled Call Log'),
FILTER(
'Compiled Call Log',
'Compiled Call Log'[Phone Number] = EARLIER('SQL_Enquiries'[Phone Number]) &&
'Compiled Call Log'[Call Time] >= EARLIER('SQL_Enquiries'[Min call date window]) &&
'Compiled Call Log'[Call Time] <= EARLIER('SQL_Enquiries'[Max call date window])
)
)
)
Explanation:
This modification should allow the measure to correctly evaluate the count of phone calls related to each enquiry, considering the date range conditions for each row in 'SQL_Enquiries'.
If I answered your question, please mark my post as solution, Appreciate your Kudos.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Amazing - thank you very much!
Am I correct in assuming the variable declared is for improved readability to understand the SUMX is iterating for each record?
Many thanks
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |