cancel
Showing results for
Did you mean:
Frequent Visitor

## Return date when expected goal is reached

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.

1 ACCEPTED SOLUTION
Community Support

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.

6 REPLIES 6
Frequent Visitor

Hi @lbendlin, i placed it on the dropbox account: PBIX file with data

Community Support

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

Frequent Visitor

Hi @v-kkf-msft , any chance to look at the problem?

Community Support

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.

Frequent Visitor

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 😁

Super User

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.

Announcements

#### Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

#### Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

#### Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors
Top Kudoed Authors