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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Natalia10000
Frequent Visitor

Add columns to ALLEXCEPT formula only if the columns are filtered

Hello,

 

I have the following measure

PercentageofTotal2 =
var TotalKPI = CALCULATE(
                    [Calculation KPI],
                    ALLEXCEPT(dimarticle,dimarticle[MerchandiseCategoryACGDesc],dimarticle[ProductAllocation]))
RETURN
 DIVIDE([Calculation KPI],TotalKPI)
 
I would like to add additional columns from table dimarticle to ALLEXCEPT but only if the user will filter them, so e.g.  there is slicer dimarticle[Category], so if the user filters sth in this slicer, the formula should look like that:
 
PercentageofTotal2 =
var TotalKPI = CALCULATE(
                    [Calculation KPI],
                         ALLEXCEPT(dimarticle,dimarticle[MerchandiseCategoryACGDesc],dimarticle[ProductAllocation],dimarticle[Category]))
RETURN
 DIVIDE([Calculation KPI],TotalKPI)
 
Could You please help me with that?
 
Kind reagrds,
 
Natalia
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Natalia10000 ,

 

I understand what you mean, but there is no way to dynamically add parameters to ALLEXCEPT, the method in reply 2 is an alternative. Or you could consider the ALLSELECTED function and see if it achieves your desired result.

 

PercentageofTotal2 =
var TotalKPI = CALCULATE(
                    [Calculation KPI],
                    ALLSELECTED(dimarticle))
RETURN
 DIVIDE([Calculation KPI],TotalKPI)

 

Best Regards,

Neeko Tang

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Natalia10000 ,

 

You can use ISFILTERED function to check if a column is being filtered. 

PercentageofTotal2 =
VAR TotalKPI1 =
    CALCULATE (
        [Calculation KPI],
        ALLEXCEPT (
            dimarticle,
            dimarticle[MerchandiseCategoryACGDesc],
            dimarticle[ProductAllocation]
        )
    )
VAR _1 =
    DIVIDE ( [Calculation KPI], TotalKPI1 )
VAR TotalKPI2 =
    CALCULATE (
        [Calculation KPI],
        ALLEXCEPT (
            dimarticle,
            dimarticle[MerchandiseCategoryACGDesc],
            dimarticle[ProductAllocation],
            dimarticle[Category]
        )
    )
VAR _2 =
    DIVIDE ( [Calculation KPI], TotalKPI2 )
RETURN
    IF ( ISFILTERED ( dimarticle[Category] ), _2, _1 )

 

Best Regards,

Neeko Tang

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

Thank You, but do You know another way? Because I would need to add more to ALLEXCEPT because I have several filters on dimarticle, if I would use ISFILETERED that would mean lots of conditions

Anonymous
Not applicable

Hi @Natalia10000 ,

 

I understand what you mean, but there is no way to dynamically add parameters to ALLEXCEPT, the method in reply 2 is an alternative. Or you could consider the ALLSELECTED function and see if it achieves your desired result.

 

PercentageofTotal2 =
var TotalKPI = CALCULATE(
                    [Calculation KPI],
                    ALLSELECTED(dimarticle))
RETURN
 DIVIDE([Calculation KPI],TotalKPI)

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.