Forum Discussion

LotteLaugesen's avatar
4 years ago
Solved

SELECTEDVALUE in calculation not working

Hi 

I have a filter this filter: 

and I'm trying to do a calculation depending the selected Item Type

 

Calculation no 1 is working fine and gives me the correct result, but no 2 and 3 are not working they return blank value.

 

1. CALCULATE(SUM(FT_StockTransactionsDetailed[Kg]),Dim_Items[Item Type]="B-Grade")
2. CALCULATE(SUM(FT_StockTransactionsDetailed[Kg]),Dim_Items[Item Type]="Waste")
3. CALCULATE(SUM(FT_StockTransactionsDetailed[Kg]),Dim_Items[Item Type]=SELECTEDVALUE(Dim_Items[Item Type]))
 
Can anybody give me a hint?
 
BR 
Lotte
 
  • LotteLaugesen's avatar
    LotteLaugesen
    4 years ago

    Thank you for asking ðŸ˜Š
    Because then I came to the thought that I have removed the interaction between the filter and report 🙄 - stupid me and sorry 
     

8 Replies

  • nandukrishnavs's avatar
    nandukrishnavs
    Icon for Community Champion rankCommunity Champion

    LotteLaugesen  Try this 

     

    VAR _selectedType =
        CALCULATE ( SELECTEDVALUE ( Dim_Items[Item Type] ) )
    VAR _result =
        CALCULATE (
            SUM ( FT_StockTransactionsDetailed[Kg] ),
            FILTER ( Dim_Items, Dim_Items[Item Type] = _selectedType )
        )
    RETURN
        _result

     

     

      • nandukrishnavs's avatar
        nandukrishnavs
        Icon for Community Champion rankCommunity Champion

        LotteLaugesen  My bad. If there is a relationship between FT_StockTransactionsDetailed and  Dim_Items, then you don't need to specify it again in the filter parameter. Can you explain your scenario?

  • Mikelytics's avatar
    Mikelytics
    Icon for Resident Rockstar rankResident Rockstar

    LotteLaugesen 

     

    Can you please try this

     

    CALCULATE(SUM(FT_StockTransactionsDetailed[Kg]),ALL(Dim_Items[Item Type]),Dim_Items[Item Type]="Waste")

     

    or

     

    CALCULATE(SUM(FT_StockTransactionsDetailed[Kg]),ALL(Dim_Items),Dim_Items[Item Type]="Waste")

     

    ________________________

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

    Click on the Thumbs-Up icon if you like this reply.

  • Hi LotteLaugesen 

     

    Try these 3:

    1. CALCULATE(SUM(FT_StockTransactionsDetailed[Kg]),Filter(All(Dim_Items),Dim_Items[Item Type]="B-Grade"))
    2. Dim_Items
    3. SUM(FT_StockTransactionsDetailed[Kg]) -- IF there is a relationship between "FT_StockTransactionsDetailed" and "Dim_Items", when you select an item on slicer, that will filter the connected table as well.
     
     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/


     

    • LotteLaugesen's avatar
      LotteLaugesen
      Icon for Helper V rankHelper V

      Thank you for answering, but it was me that made a mistake, so I close the case