Forum Discussion

PowerBITestingG's avatar
PowerBITestingG
Icon for Resolver I rankResolver I
3 years ago
Solved

Iterate through a measure

I have been looking around the forum to find the answer but no luck yet

 

I have this table

CountryCondition

Quantity (measure)

Wanted measure
France1515
Italy0215
Spain11015

 

I want to basically get the total of my Quantity measure based on the condition

 

I would have thought = sumx(filter(table,condition<>1), Quantity ( measure)) would have done the trick, but it brings the exact same result. I am filtering the table.

 

  • PowerBITestingG I would think:

    Wanted measure =
      VAR __Table = SUMMARIZE(ALLSELECTED('Table'),[Country],[Condition],"Quantity",[Quantity])
    RETURN
      SUMX(FILTER(__Table,[Condition] = 1),[Quantity])

5 Replies

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

    PowerBITestingG I would think:

    Wanted measure =
      VAR __Table = SUMMARIZE(ALLSELECTED('Table'),[Country],[Condition],"Quantity",[Quantity])
    RETURN
      SUMX(FILTER(__Table,[Condition] = 1),[Quantity])
    • PowerBITestingG's avatar
      PowerBITestingG
      Icon for Resolver I rankResolver I

      Greg_Deckler  Can you see any future issues from using allselected inside a sumx? or we are not using it directly in it, so its not a problem?

       

      Thank you!

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

        PowerBITestingG ALLSELECTED just removes the direct filters within the visual, so in this case Country and Condition, for example. It preserves all of the other filters coming from visual selections in other visuals. You can use ALLSELECTED on it's own, wrapped in a FILTER or SUMMARIZE or any other function that expects a table of values as a parameter. No, it is not resticted for sole use in CALCULATE but a lot of people seem to believe that is the case.