Forum Discussion

eunji888888's avatar
eunji888888
Frequent Visitor
1 year ago

MAXX measure wrong value

I found that there is a mistaken value in the MAXX function. The maxx gives all the same value, 24, which is the maximum for the whole list instead of filtering the selected material. Are there anyone know how to solve it?

 

Below is my original testing discount measure: 
 
Discount Measure =
VAR CurrentMaterial = SELECTEDVALUE('By SO'[Material])
VAR CurrentNetCase = SUM('By SO'[NetCase])
VAR CurrentBillingDocNo = SELECTEDVALUE('By SO'[BillingDocNo])
VAR ScalarValue =
    CALCULATE(
        MAXX(
            FILTER(
                'Combined Group Discount',
                'Combined Group Discount'[Material Group.Material] = CurrentMaterial
            ),
            VALUE(RIGHT('Combined Group Discount'[Column], LEN('Combined Group Discount'[Column]) - FIND("_", 'Combined Group Discount'[Column])))
        )
    )
VAR IsScalarValueFound = NOT(ISBLANK(ScalarValue))
RETURN
IF(
    IsScalarValueFound && CurrentNetCase >= ScalarValue,
   "apply", // Replace with your discount logic
    "No Discount"
)
 

6 Replies

  • Ray_Minds's avatar
    Ray_Minds
    Solution Supplier

    Hi  eunji888888

    I have tried to replicate your scenario which is as follows: 

     

    1. By SO table  
     

     

     

    2. Combined Group Discount table 
     

     

     

    By looking at the above sample data I provided for both tables, we can deduce: 

    (I) For Material A, max value will be 25 (Extracted from Discount field). 

    (II) For Material B, max value will be 30 (Extracted from Discount field). 

    (III) For Material C, max value will be 20 (Extracted from Discount field). 

     

    Visual Output : 

    For A 

     

    For B 

     

    For C 

     

     

     

     

     

    Matching as expected. In my model, I am utilizing a bridge table to establish a relationship between the 'By So' and 'Combine Group Discount' tables, as I anticipate that both tables contain duplicate values in the material column. If you could kindly share a sample dataset along with the relationships you have defined, it would greatly facilitate troubleshooting and help us resolve the issue more efficiently. Thank you! 

    If your requirement is solved, please make THIS ANSWER a SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.

  • Hi eunji888888 Try adding this in the filter after Value 'Combined Group Discount'[Material Group.Material] = CurrentMaterial inside calculate here is the full code 

    Discount Measure =
    VAR CurrentMaterial = SELECTEDVALUE('By SO'[Material])
    VAR CurrentNetCase = SUM('By SO'[NetCase])
    VAR CurrentBillingDocNo = SELECTEDVALUE('By SO'[BillingDocNo])
    VAR FilteredScalarValue =
        CALCULATE(
            MAXX(
                FILTER(
                    'Combined Group Discount',
                    'Combined Group Discount'[Material Group.Material] = CurrentMaterial
                ),
                VALUE(RIGHT(
                    'Combined Group Discount'[Column],
                    LEN('Combined Group Discount'[Column]) - FIND("_", 'Combined Group Discount'[Column])
                ))
            ),
            'Combined Group Discount'[Material Group.Material] = CurrentMaterial//Explicily add this
        )
    VAR IsScalarValueFound = NOT(ISBLANK(FilteredScalarValue))
    RETURN
    IF(
        IsScalarValueFound && CurrentNetCase >= FilteredScalarValue,
        "apply", // Replace with your discount logic
        "No Discount"
    )
    • eunji888888's avatar
      eunji888888
      Frequent Visitor

      I have tried your measure, but it does not change the result

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi eunji888888,

     

    Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

    If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.

     

    Best regards,

    Prasanna Kumar

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi eunji888888,

     

    We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.

    If the issue is resolved, we’d appreciate it if you could mark the helpful reply as Accepted Solution — it helps others who might face a similar issue.

     

    Warm regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi eunji888888,

     

    Just a gentle reminder — has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.

    This not only closes the loop on your query but also helps others in the community solve similar issues faster.

    Thank you for your time and feedback!

     

    Best,

    Prasanna Kumar