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

SELECTEDVALUE-1 not working in a measure

Hi All, i am trying to calculate the max value from a selected date and am using the below measure which is working fine

 

Max Peak Value Selected Date A =

CALCULATE (

MAX (TableXYZ[Col B]), TableXYX[Col A] = "123"

&& TableXYZ[Reporting_Date] = SELECTEDVALUE ( 'Calendar Dim'[Date] ) )

 

I now want to calculate the max value for the day before the selected date and when i put in a SELECTEDVALUE ( 'Calendar Dim'[Date] )-1 i get blank

 

Max Peak Value Selected Date A =

CALCULATE (

MAX (TableXYZ[Col B]), TableXYX[Col A] = "123"

&& TableXYZ[Reporting_Date] = SELECTEDVALUE ( 'Calendar Dim'[Date] ) -1)

 

i have created a measure and seen in a card i am getting the previous date to the selected one - Selected Date - 1 = SELECTEDVALUE('Calendar Dim'[Date])-1

 

i dont understand why it isnt working in the measure. thanks amrita

1 ACCEPTED SOLUTION
amrosullivan
Frequent Visitor

this worked:

Max Peak Value Selected Date - 2 =
VAR _t2 = Dateadd('Calendar Dim'[Date],-2,DAY
Return
CALCULATE (
MAX (TableXYZ[Col B])
, TableXYX[Col A] = "123", 
FILTER(ALL(TableXYZ),TableXYZ[Reporting_Date] = _t2)
)

View solution in original post

6 REPLIES 6
amrosullivan
Frequent Visitor

this worked:

Max Peak Value Selected Date - 2 =
VAR _t2 = Dateadd('Calendar Dim'[Date],-2,DAY
Return
CALCULATE (
MAX (TableXYZ[Col B])
, TableXYX[Col A] = "123", 
FILTER(ALL(TableXYZ),TableXYZ[Reporting_Date] = _t2)
)
Samarth_18
Super User
Super User

Hi @amrosullivan ,

Please try this:-

Max Peak Value Selected Date A =
VAR selected_date =
    SELECTEDVALUE ( 'Calendar Dim'[Date] ) - 1
RETURN
    CALCULATE (
        MAX ( TableXYZ[Col B] ),
        TableXYX[Col A] = "123"
            && TableXYZ[Reporting_Date] = selected_date
    )

 

BR,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi that is still returning blank.

@amrosullivan , I am hoping you have checked the data and It have some data for selected date..right?

You could also try this:-

Max Peak Value Selected Date A =
VAR selected_date =
    SELECTEDVALUE ( 'Calendar Dim'[Date] ) - 1
RETURN
    CALCULATE (
        MAX ( TableXYZ[Col B] ),
        FILTER (
            TableXYX,
            TableXYX[Col A] = "123"
                && TableXYZ[Reporting_Date] = selected_date
        )
    )

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

this is returning blank too.

i do have data for the previous date. when ir emove the - 1 and select the previous date i det the required value.

thanks!

@amrosullivan is it possible for you to share your PBI after removing sensitive data?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

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