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.
Hello Forum,
I have a series of Measures I am trying to use to identify the first instance of a Customer placing an Order.
I need to accomplish three things:
I am able to accomplish one and two, but my third Measure is giving unexpected results. Why are the highlighted values appearing as blank?
__NewAccounts_A_FirstOrderDate:
__NewAccounts_A_FirstOrderDate =
var maxContextDate = MAX( Dates[Date] )
RETURN
CALCULATE(
MIN( Sales[Delivery Date] ),
ALLEXCEPT(
'Sales' ,
Customer[Customer No.],
--Customer[Customer],
Supplier[Supplier],
Location[Branch]
),
Sales[DeliveryDate] >= DATE( YEAR( maxContextDate ) - 1, 1, 1),
Sales[Delivery Quantity] > 0
)
__NewAccounts_B_FirstOrderInContext:
__NewAccounts_B_FirstOrderInContext =
var maxContextDate = MAX( Dates[Date] )
return
IF(
[__NewAccounts_A_FirstOrderDate] >= DATE( YEAR( maxContextDate ), 1, 1) && [__NewAccounts_A_FirstOrderDate] <= maxContextDate,
1,
0
)
__NewAccounts_C_DistinctNewCustomers:
__NewAccounts_C_DistinctNewCustomers =
CALCULATE(
DISTINCTCOUNT( Customer[Customer No.] ),
FILTER(
Sales,
[__NewAccounts_B_FirstOrderInContext] = 1
)
)
Hi ALL,
Firstly Dangar332 thank you for your solution!
And @VBAmazing ,I tried to use your code to run it in the example data I created but he seems to be running fine, since you can't show your example data, can you reproduce your problem based on the pbix file I provided.
You can contact me anytime and I will get back to you as soon as I receive your message, looking forward to hearing from you!
Hi, @VBAmazing
Can you provide some sample Data and clarify your scenario in detail.
@Dangar332 Thank you for your reply. The data is sensitive and unfortunately cannot be shared in a .PBIX, though that would be ideal.
However the scenario is:
Now I need to be able to Count the Distinct Customer IDs where the minimum date falls in the context.
Currently - as in my screenshot above - You can see those measures in action.
However, I am only able to count the distinct Customer IDs in some of my rows.
Based on my current understanding of the logic, I should be getting a 1 in each __NewAccounts_C_DistinctNewCustomers row where __NewAccounts_B_FirstOrderInContext is 1, but that's not the case.
User | Count |
---|---|
15 | |
13 | |
12 | |
10 | |
10 |
User | Count |
---|---|
19 | |
15 | |
14 | |
11 | |
10 |