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
raymond
Post Patron
Post Patron

Calculate Number of Days until a Value doubles

Hello community,

 

can onyone help me to calculate the number of days until a value doubles? I have searched online but couldnt find helpful ressources. Does anyone have something at hand?

 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @raymond 

 

Based on my research, you may create a measure as below.

 

 

CountDays = 
var _maxdate = 
CALCULATE(
    MAX('Table'[Date]),
    ALLSELECTED('Table')
)

var _maxvalue = 
LOOKUPVALUE(
    'Table'[Value],
    'Table'[Date],
    _maxdate
)

var _halfvaluedate = 
LOOKUPVALUE(
    'Table'[Date],
    'Table'[Value],
    CALCULATE(
        MAX('Table'[Value]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Value]<=_maxvalue/2
        )
    )
)

return
DATEDIFF(
    _halfvaluedate,
    _maxdate,
    DAY
)+1

 

 

 

Result:

d1.png

 

Best Regards

Allan

 

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

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @raymond 

 

Based on my research, you may create a measure as below.

 

 

CountDays = 
var _maxdate = 
CALCULATE(
    MAX('Table'[Date]),
    ALLSELECTED('Table')
)

var _maxvalue = 
LOOKUPVALUE(
    'Table'[Value],
    'Table'[Date],
    _maxdate
)

var _halfvaluedate = 
LOOKUPVALUE(
    'Table'[Date],
    'Table'[Value],
    CALCULATE(
        MAX('Table'[Value]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Value]<=_maxvalue/2
        )
    )
)

return
DATEDIFF(
    _halfvaluedate,
    _maxdate,
    DAY
)+1

 

 

 

Result:

d1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

It should work a little like this. Depending on the date selection one makes, the measure should calculate the number of days that are between the largest value (here accumulated) and half of the value.

 

 

2020-04-01 09_11_43-Mappe1 - Excel.png2020-04-01 09_11_59-Mappe1 - Excel.png2020-04-01 09_12_09-Mappe1 - Excel.png

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.