Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
robin_ozc
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

HPHC
2000
3000
50050
750100

 

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
111 2021-02-01  2021-04-01
210 2021-12-14  2022-04-04
300 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!

1 ACCEPTED 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 )
)

vkkfmsft_0-1643269669377.png

 

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.

image.png


If you don't keep any filters then you can use these columns in the visual.

vkkfmsft_1-1643272407287.png

 

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.

View solution in original post

6 REPLIES 6
robin_ozc
Frequent Visitor

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

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?

 

vkkfmsft_2-1643089818495.png

vkkfmsft_1-1643089555536.png

 

Best Regards,
Winniz

 

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

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 )
)

vkkfmsft_0-1643269669377.png

 

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.

image.png


If you don't keep any filters then you can use these columns in the visual.

vkkfmsft_1-1643272407287.png

 

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.

Anonymous
Not applicable

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 😁

lbendlin
Super User
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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.