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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
eunji888888
Frequent Visitor

give the max(tradediscountprice) for all in the custgroup, but not in the selected channel descripti

It give the max(tradediscountprice) for all in the custgroup, but not in the selected channel description. How to solve?
 
StdPrice =
VAR EANValue = SELECTEDVALUE('CustGroup4 Material'[#EAN])
VAR ChannelValue = SELECTEDVALUE('SO'[Channel Description])
var CustGroup= SELECTEDVALUE('CustGroup4 Material'[#CustGroup4_Channel Description])
 
VAR TradeDiscountPrice =
    CALCULATE(
        MAXX(FILTER(ALLEXCEPT('CustGroup4 Material', 'CustGroup4 Material'[#EAN], 'A814 CustGroup4 Material'[#CustGroup4_Channel Description]), RIGHT('CustGroup4 Material'[#ConditionType Description],1)= "%"), 'CustGroup4 Material'[StdPrice]),
        'CustGroup4 Material'[Promotion yes/no] = "Promotion Disc"
    )
 
RETURN TradeDiscountPrice
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @eunji888888 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"SO"

vnuocmsft_0-1731050703227.png

 

"CustGroup4 Material"

vnuocmsft_1-1731050717579.png

 

I have made changes to your code as follows:

 

Measure StdPrice = 
VAR EANValue = SELECTEDVALUE('CustGroup4 Material'[#EAN])
VAR ChannelValue = SELECTEDVALUE('SO'[Channel Description])
VAR CustGroup = SELECTEDVALUE('CustGroup4 Material'[#CustGroup4_Channel Description])
VAR TradeDiscountPrice =
    CALCULATE(
        MAXX(
            FILTER(
                ALLEXCEPT('CustGroup4 Material', 'CustGroup4 Material'[#EAN]),
                RIGHT('CustGroup4 Material'[#ConditionType Description], 1) = "%" &&
                'CustGroup4 Material'[#CustGroup4_Channel Description] = ChannelValue
            ),
            'CustGroup4 Material'[StdPrice]
        ),
        'CustGroup4 Material'[Promotion yes/no] = "Promotion Disc"
    )

RETURN TradeDiscountPrice

 

Here is the result.

 

 

vnuocmsft_2-1731050972848.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @eunji888888 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"SO"

vnuocmsft_0-1731050703227.png

 

"CustGroup4 Material"

vnuocmsft_1-1731050717579.png

 

I have made changes to your code as follows:

 

Measure StdPrice = 
VAR EANValue = SELECTEDVALUE('CustGroup4 Material'[#EAN])
VAR ChannelValue = SELECTEDVALUE('SO'[Channel Description])
VAR CustGroup = SELECTEDVALUE('CustGroup4 Material'[#CustGroup4_Channel Description])
VAR TradeDiscountPrice =
    CALCULATE(
        MAXX(
            FILTER(
                ALLEXCEPT('CustGroup4 Material', 'CustGroup4 Material'[#EAN]),
                RIGHT('CustGroup4 Material'[#ConditionType Description], 1) = "%" &&
                'CustGroup4 Material'[#CustGroup4_Channel Description] = ChannelValue
            ),
            'CustGroup4 Material'[StdPrice]
        ),
        'CustGroup4 Material'[Promotion yes/no] = "Promotion Disc"
    )

RETURN TradeDiscountPrice

 

Here is the result.

 

 

vnuocmsft_2-1731050972848.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

SolomonovAnton
Super User
Super User

To ensure that the MAX(tradediscountprice) function considers only the CustGroup and filters by the selected Channel Description, you need to incorporate the Channel Description filter in your calculation. Here’s how to modify your DAX code: Include Channel Description as a filtering condition in the CALCULATE function. Use the ALLEXCEPT function with Channel Description as an additional parameter to keep it in the current context.


StdPrice =
VAR EANValue = SELECTEDVALUE('CustGroup4 Material'[#EAN])
VAR ChannelValue = SELECTEDVALUE('SO'[Channel Description])
VAR CustGroup = SELECTEDVALUE('CustGroup4 Material'[#CustGroup4_Channel Description])

VAR TradeDiscountPrice =
CALCULATE(
MAXX(
FILTER(
ALLEXCEPT(
'CustGroup4 Material',
'CustGroup4 Material'[#EAN],
'CustGroup4 Material'[#CustGroup4_Channel Description],
'SO'[Channel Description] // Keep Channel Description in context
),
RIGHT('CustGroup4 Material'[#ConditionType Description], 1) = "%"
),
'CustGroup4 Material'[StdPrice]
),
'CustGroup4 Material'[Promotion yes/no] = "Promotion Disc",
'SO'[Channel Description] = ChannelValue // Filter for selected Channel Description
)

RETURN TradeDiscountPrice

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.