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

Mahesh0016_0-1669981497300.png

 

Mahesh0016
Super User
Super User

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