cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zorrro
Frequent Visitor

minimum value between 2 dates

Hello,

 

I want to calcule a minimum and maximum for value that i have in table X. But i want to have the minimum and maximum between 2 dates that i have in table Y. 

 

Exemple : 

Table X : 

ARTDateValue
refe128/11/2022 
refe129/11/2022 
refe130/11/2022 
refe228/11/2022 
refe230/11/2022 

 

Table Y : 

ARTDate ADate B
refe128/11/202230/11/2022
refe101/12/202204/12/2022
refe228/11/202230/11/2022
refe201/12/202204/12/2022

 

I tried : 

 

MINX(

    KEEPFILTERS(DATESBETWEEN('TableX'[dateFormatted],'TableY'[DATE A],'CBANOQ1'[DATE B])),

    CALCULATE(SUM('TableX'[Value]))

)

 

Thank you for your help

1 ACCEPTED SOLUTION

Hi, @zorrro 

Please try formula like:

minimum =
CALCULATE (
    MIN ( TableX[Value] ),
    FILTER (
        TableX,
        TableX[ART] = SELECTEDVALUE ( TableY[ART] )
            && TableX[Date] >= SELECTEDVALUE ( TableY[Date A] )
            && TableX[Date] <= SELECTEDVALUE ( TableY[Date B] )
    )
)

Your expected result seems to have wrong value, please check again.

Result:

veasonfmsft_0-1670233671013.png

Best Regards,
Community Support Team _ Eason

View solution in original post

10 REPLIES 10
Mahesh0016
Solution Sage
Solution Sage

Mahesh0016_0-1669981497300.png

 

Mahesh0016
Solution Sage
Solution Sage

Mahesh0016_1-1669981378621.png

MaxValue = CALCULATE(MAX(X[Value]),DATEDIFF(Y[Date A],Y[Date B],DAY),ALLEXCEPT(X,X[ART]))
MinValue = CALCULATE(MIN(X[Value]),DATEDIFF(Y[Date A],Y[Date B],DAY),ALLEXCEPT(X,X[ART]))

 

Hello,

 

I tried your suggestion but it's donesn't work.

 

I add a exemple in the tables just to be more specific for the result that i want : 

 

zorrro_0-1669985727712.png

Thanks for your hepl

Hi, @zorrro 

Please try formula like:

minimum =
CALCULATE (
    MIN ( TableX[Value] ),
    FILTER (
        TableX,
        TableX[ART] = SELECTEDVALUE ( TableY[ART] )
            && TableX[Date] >= SELECTEDVALUE ( TableY[Date A] )
            && TableX[Date] <= SELECTEDVALUE ( TableY[Date B] )
    )
)

Your expected result seems to have wrong value, please check again.

Result:

veasonfmsft_0-1670233671013.png

Best Regards,
Community Support Team _ Eason

zorrro
Frequent Visitor

TableX: 

ARTDate

Value

refe128/11/2022

3

refe129/11/2022

5

refe130/11/2022

6

refe101/12/2022

7

refe102/12/2022

9

refe103/12/2022

5

refe104/12/2022

8

refe228/11/2022

4

refe230/11/2022

7

refe202/12/2022

10

refe203/12/2022

17

 

TableY: 

ARTDate ADate B

output

refe128/11/202230/11/2022

3

refe101/12/202204/12/2022

5

refe229/11/202230/11/2022

4

refe202/12/202203/12/2022

10

NikhilChenna
Continued Contributor
Continued Contributor

Hi @zorrro , Can you share the expected output result too. 

 

 

@NikhilChenna 

Hello, I shared the expected output. Can you check and give me your opinion ?

Thanks

 

 

v-easonf-msft
Community Support
Community Support

Hi, @zorrro 

The fields in your formula don't seem to match the fields in your table.

Can you share your expected output to further explain your requirement?

Best Regards,
Community Support Team _ Eason

 

@v-easonf-msft 

Hello, I shared the expected output. Can you check and give me your opinion ?

Thanks

TableX: 

ARTDate

Value

refe128/11/2022

3

refe129/11/2022

5

refe130/11/2022

6

refe101/12/2022

7

refe102/12/2022

9

refe103/12/2022

5

refe104/12/2022

8

refe228/11/2022

4

refe230/11/2022

7

refe202/12/2022

10

refe203/12/2022

17

 

TableY: 

ARTDate ADate B

output

refe128/11/202230/11/2022

3

refe101/12/202204/12/2022

5

refe229/11/202230/11/2022

4

refe202/12/202203/12/2022

10

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors