Forum Discussion

MichaelaMul's avatar
MichaelaMul
Helper III
2 years ago
Solved

Using ALLSELECTED in Divide function

Hi everyone! I made the following measures to get the volume share of each category in a specific brand in my dataset. The two top measures are working properly, with the category measure filtering properly when selected. However, when I combine the two measures to divide it the ALLSELECTED measure stops working. What am I doing wrong?

Total for Category = 
CALCULATE (SUM('DATA'[Volume]), 'DATA'[Brand] = "ABC", ALLSELECTED('CategoryTable'[Category]))

Total for Brand = 
CALCULATE (SUM('DATA'[Volume]), 'DATA'[Brand] = "ABC")

Total for Category divided by Total for Brand =
DIVIDE([Total for Category], [Total for Brand])

Thanks!

12 Replies

  • You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi MichaelaMul ,

     

    Thanks for the reply from lbendlin .

     

    I do not really know what kind of desired effect you want.

     

    What do SUM('DATA'[CY Reforecast] and SUM('DATA'[Volume]) mean respectively? Why do you divide them?

     

    I would appreciate it if you could provide me with sample data and a diagram of the desired effect, please remove any sensitive data in advance.

     

    If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    • MichaelaMul's avatar
      MichaelaMul
      Helper III

      Hi thanks for the reply! I made a typo and updated the formulas above. Here's the sample data.

       

      CategoryTable:

      Product GroupCategory
      LIGHT SOUR CREAMSOUR CREAM
      SOUR CREAMSOUR CREAM
      SKIM MILKMILK
      WHOLE MILKMILK
      1% MILKMILK
      2% MILKMILK
      ORANGE JUICE DRINKS
      CREAMER CREAMER
      NON-DAIRY CREAMER CREAMER
      LIGHT CREAMCREAMER
      SPRING WATER DRINKS

       

      DATA table:

      StoreBrandProduct GroupTime PeriodVolume
      STORE AABCLIGHT SOUR CREAMMarch12,525
      STORE AABCLIGHT SOUR CREAMFebruary11,340
      STORE AABCLIGHT SOUR CREAMJanuary9,720
      STORE AABCSOUR CREAMMarch42,134
      STORE AABCSOUR CREAMFebruary35,280
      STORE AABCSOUR CREAMJanuary26,880
      STORE AABCSKIM MILKMarch1,645
      STORE AABCSKIM MILKFebruary1,476
      STORE AABCSKIM MILKJanuary1,684
      STORE AABCSKIM MILKMarch5,300
      STORE AABCWHOLE MILKFebruary5,157
      STORE AABCWHOLE MILKJanuary5,711
      STORE AABCWHOLE MILKMarch7,900
      STORE AABCWHOLE MILKFebruary7,408
      STORE AABCWHOLE MILKJanuary8,632
      STORE AABCWHOLE MILKFebruary3
      STORE AABCSKIM MILKJanuary4
      STORE AABCSKIM MILKMarch711
      STORE AABCSKIM MILKFebruary667
      STORE AABCSKIM MILKJanuary712
      STORE AABCORANGE JUICE March65
      STORE AABCORANGE JUICE February59
      STORE AABCORANGE JUICE January95
      STORE AABCORANGE JUICE March154
      STORE AABC2% MILKFebruary136
      STORE AABC2% MILKJanuary148
      STORE AABC2% MILKMarch228
      STORE AABC2% MILKFebruary212
      STORE AABC2% MILKJanuary226
      STORE AABCCREAMER March87
      STORE AABCCREAMER February105
      STORE AABCCREAMER January102
      STORE AABCNON-DAIRY CREAMER March8,237
      STORE AABCNON-DAIRY CREAMER February7,440
      STORE AABCNON-DAIRY CREAMER January3,360

       

      Thanks!