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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
mattih
Frequent Visitor

Filter calculation to apply only on spesific values

Hi,

 

I have created a measure "Quantity (KG) wich shows a value for different weight classes (L, M, S, XL and ML). Now I would need to divide the quantity for weight class ML and add the value ONLY to weight classes M and L.

 

I created the following measure to get the divided value for weight class ML:

 

ML Divide = CALCULATE([Quantity (KG)];'Item'[Weight Class]="ML")/2

 

Now when added to a table it looks like this:

 

mattih_1-1610025986089.png

 

Is it possible to modify the measure so that the ML Divide value only shows in weight classes L and M and in weight classes S and XL it would be blank?

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
AntrikshSharma
Super User
Super User

@mattih  Try this:

ML Divide =
DIVIDE (
    CALCULATE (
        [Quantity (KG)],
        KEEPFILTERS ( 'Item'[Weight Class] IN { "M", "L" } )
    ),
    2
)

 

View solution in original post

5 REPLIES 5
AntrikshSharma
Super User
Super User

@mattih  Try this:

ML Divide =
DIVIDE (
    CALCULATE (
        [Quantity (KG)],
        KEEPFILTERS ( 'Item'[Weight Class] IN { "M", "L" } )
    ),
    2
)

 

Thanks, this was a little closer but I will try to explain more.

 

1. Quantity (KG) needs to be divided by weight class ML so we need the filter for it. ML is its own weight class:

 

ML Divide = CALCULATE([Quantity (KG)];'Item'[Weight class]="ML")/2

 

2. Now we get the divided sum of weight class ML:

mattih_0-1610099830331.png

So 1007,9 / 2 = 503,97.

 

3. Now I would need to ADD the divided value of ML weight class to weight classes L and M values but keep the same Quantity (KG) values for classes S and XL. I tried implementing your suggestion to a second measure:

 

Quantity (KG) 2 =
IF([ML Divide]<>BLANK();CALCULATE([Quantity (KG)];KEEPFILTERS('Item'[Weight Class] IN { "M"; "L" }))+[ML Divide];[Quantity (KG)])

 

4. With this measure I get the summarization correctly for weight classes M and L but for some reason it returns the value of ML Divide to classes S and XL where I would like it to return the value of Quantity (KG):

 

mattih_1-1610100860543.png

 

mattih
Frequent Visitor

I managed to get it working by changing the ML Divide measure like so:

 

ML Divide = IF(CALCULATE([Quantity (KG)];KEEPFILTERS('Item'[Weight Class] IN { "M"; "L" }));CALCULATE([Quantity (KG)];'Item'[Weight Class]="ML")/2;BLANK())

 

Thank you very much for the suggestion @AntrikshSharma !

kumar27
Advocate V
Advocate V

ML Divide = DIVIDE( Quantity (KG)],2)
ANd then chosse the filters for this visual as Weight class L ans M from filter section 

 

Thanks, but the other weight classes still need to be shown in the visual.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.