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.
Hi all,
i'm trying to write a DAX formule to return a date when a certain number is reached. So i have 2 tables:
The first one is a table containing the minimum goals for HP and HC
HP | HC |
200 | 0 |
300 | 0 |
500 | 50 |
750 | 100 |
The second table contains all addresses and an integer whether or not HP or HC has been met.
address_id | isHP | isHC | date_hp | date_hc |
1 | 1 | 1 | 2021-02-01 | 2021-04-01 |
2 | 1 | 0 | 2021-12-14 | 2022-04-04 |
3 | 0 | 0 | 2022-02-01 | 2022-06-19 |
Let's assume the current isHP = 199 and isHC = 48. Reaching isHP = 200 would be on 2022-02-01 and Reaching isHC = 50 would be 2022-06-19, how should i write the DAX for this?
I hope my question is clear and someone can point me in the right direction.
Tnx in advance!
Solved! Go to Solution.
Hi @robin_ozc ,
I add a Date column to the data table.
Date =
IF (
[workon_digging_start_planned] = "",
BLANK (),
LEFT ( [workon_digging_start_planned], 10 )
)
Then create the following measures.
ishcTotal =
CALCULATE (
SUM ( data[ishc] ),
FILTER (
ALL ( data ),
data[project_id] = MAX ( data[project_id] )
&& data[Date] <= MAX ( data[Date] )
)
)
ishpTotal =
CALCULATE (
SUM ( data[ishp] ),
FILTER (
ALL ( data ),
data[project_id] = MAX ( data[project_id] )
&& data[Date] <= MAX ( data[Date] )
)
)
Measure =
IF (
ISBLANK ( SUM ( Planning[HC Goal] ) ) && ISBLANK ( SUM ( Planning[HP Goal] ) ),
BLANK ( ),
CALCULATE (
MIN ( data[Date] ),
FILTER (
data,
[ishcTotal] >= SUM ( Planning[HC Goal] )
&& [ishpTotal] >= SUM ( Planning[HP Goal] )
)
)
)
If you want to keep the filters for the projects[project] and contractors[contractor], then you need to add these columns in the visual.
If you don't keep any filters then you can use these columns in the visual.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @robin_ozc ,
How do you calculate the growth of isHP and isHC? Is it sorted by address column in ascending order and then calculate the number of rows?
Best Regards,
Winniz
Hi @robin_ozc ,
I add a Date column to the data table.
Date =
IF (
[workon_digging_start_planned] = "",
BLANK (),
LEFT ( [workon_digging_start_planned], 10 )
)
Then create the following measures.
ishcTotal =
CALCULATE (
SUM ( data[ishc] ),
FILTER (
ALL ( data ),
data[project_id] = MAX ( data[project_id] )
&& data[Date] <= MAX ( data[Date] )
)
)
ishpTotal =
CALCULATE (
SUM ( data[ishp] ),
FILTER (
ALL ( data ),
data[project_id] = MAX ( data[project_id] )
&& data[Date] <= MAX ( data[Date] )
)
)
Measure =
IF (
ISBLANK ( SUM ( Planning[HC Goal] ) ) && ISBLANK ( SUM ( Planning[HP Goal] ) ),
BLANK ( ),
CALCULATE (
MIN ( data[Date] ),
FILTER (
data,
[ishcTotal] >= SUM ( Planning[HC Goal] )
&& [ishpTotal] >= SUM ( Planning[HP Goal] )
)
)
)
If you want to keep the filters for the projects[project] and contractors[contractor], then you need to add these columns in the visual.
If you don't keep any filters then you can use these columns in the visual.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-kkf-msft , that was absolutely wonderful!!! Thank you so much 🙏
I have one challenge left, but i'll try to figure it out myself first before bothering you 😁
" Let's assume the current isHP = 199 and isHC = 48."
Please reflect that in your sample data. Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |