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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SK87
Helper III
Helper III

Max Value with multpile conditions (criteria based)

Hi Team,

 

I want maximum value of given attributes but there is some criteria that Value can't be below some number and greater than some number. I tried implementing DAX but results are not coming correct

 

Maximum Value of Last3 months =

VAR CA = SELECTEDVALUE ( 'Table'[A] )

VAR RefDate = MAX('Date'[SELECT MONTH])

VAR MaxValue = Calculate(MAX ( 'Table'[Value] ),

DATESINPERIOD('Previous Period'[SELECT MONTH],RefDate,-3,MONTH)

)

RETURN  

IF (

        CA = "A",  

        IF (

            MaxValue > 1000,

            Maxvalue & " ' "

           

        ),

IF (

        CA = "B",  

        IF (

            MaxValue > 30 || MaxValue < 250,

            MaxValue & " "" "

           

        ),

IF (

        CA = "C",  

        IF (

            MaxValue > 10 || MaxValue < 350,

            MaxValue & " "" "

           

        ),

          MaxValue & " "" "

   

    )))

Please suggest.

 

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @SK87 ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hi @SK87 ,

Please update the formula of measure [Maximum Value of Last3 months] as below and check if it can return the correct result...

Maximum Value of Last3 months =
VAR CA =
    SELECTEDVALUE ( 'Table'[A] )
VAR RefDate =
    MAX ( 'Date'[SELECT MONTH] )
VAR MaxValue =
    CALCULATE (
        MAX ( 'Table'[Value] ),
        DATESINPERIOD ( 'Previous Period'[SELECT MONTH], RefDate, -3, MONTH )
    )
RETURN
    IF (
        CA = "A"
            && MaxValue > 1000,
        Maxvalue & " ' ",
        IF (
            CA = "B"
                && MaxValue > 30
                && MaxValue < 250,
            MaxValue & " "" ",
            IF (
                CA = "C"
                    && MaxValue > 10
                    && MaxValue < 350,
                MaxValue & " "" ",
                MaxValue & " "" "
            )
        )
    )

If the above one not working, could you please provide the calculation logic of the above formula or the function which you want to achieve just like below sentences? It is better if you can give some sample data to explain it. Thank you.

IF XX THEN XX

IF XX THEN XX

IF XX THEN XX

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
wdx223_Daniel
Super User
Super User

maybe you want to use &&, instead of "||"

Didn't worked with that too. @wdx223_Daniel 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors