Forum Discussion

Rena's avatar
Rena
Icon for Resolver II rankResolver II
1 year ago
Solved

Measure to remove one filter but add another

I have a PBI with multiple data tables.  I am trying to do a simple basically sumif but can't seem to make it work.   I have 10 plants that make different products. 3 of those plants all make prod...
  • TheoC's avatar
    1 year ago

    Hi Rena 

     

    I hope you're doing well!

     

    I created some dummy data based on my understanding of your post.  But please let me know if the below is what you are after.  Just note that where no selection has been made in the slicer, I have just added "Choose From Slicer" to alert the user to select an option from the slicer. Otherwise, this can be adjusted to whatever you'd like:

     

     

    Once a user selects from the slicer, the results change accordingly.  Again, I've just added dummy data on the basis of what I understood. Please let me know if I've misunderstood.

     

     

    TotalVolumeForSelectedPlants = 
    
    VAR _SelectedBrand = SELECTEDVALUE ( 'Material Table'[Brand] )
    
    VAR _PlantsWithSelectedBrand =
    
        CALCULATETABLE (
            VALUES ( 'Volume Table'[Plant] ) ,
            'Volume Table'[Brand] = _SelectedBrand ,
            'Volume Table'[Actual] > 0
        )
    
    VAR _result =
    
    CALCULATE (
        [Sum of Actual Volume] ,
        'Volume Table'[Plant] IN _PlantsWithSelectedBrand,
        ALL ( 'Material Table'[Brand] )
    )
    
    RETURN
    
    IF ( ISBLANK ( _result ) , "Choose From Slicer" , _result )

     

    Hope this helps!

     

    Theo 🙂

     

  • Rena's avatar
    Rena
    1 year ago

    Got this figured out - leaving it here in case someone else needs it in the future

     

    Brand Volume Test =

    VAR SelectedBrand = SELECTEDVALUE('Material Map'[Brand])

    VAR TotalBrands =
        TREATAS(
            VALUES('Material Map'[Brand]),
            'Volume Lock'[Brand])

    VAR PlantwithBrands =
        CALCULATETABLE(
            VALUES('Volume Lock'[Plant Number]),
            'Volume Lock'[Brand] IN TotalBrands,
            'Volume Lock'[Volume]>0)

    RETURN
        CALCULATE(
            SUM('Volume Lock'[Volume]),
            'Volume Lock'[Plant Number] IN PlantwithBrands,
            ALL('Material Map'[Brand]))
     
  • TheoC's avatar
    TheoC
    1 year ago

    Hi Rena 

     

    Sorry it took so long. Required a little extra thought and then the penny dropped... a lot of the challenge was arising from using Material Table "Brand" as the Slicer given that all of the measures were reflecting the Volume Table "Brand".   I was running into the same issues until this point.

     

    I am hoping that the attached is what you are after. I have started from a blank canvas in the attached so please let me know how it all goes!  

     

    Below is an output:

     

     

     

    Hope this helps!

     

    Theo 🙂