Forum Discussion

binayjethwa's avatar
binayjethwa
Icon for Helper V rankHelper V
3 years ago

Calculate total rows based on slicer selection

Hi All, 

 

I have the following table where I have list of  Item.

To calculate weight , i need to count rows of table which is 14 and divide it by 100 as mentioned below.

Also I have a slicer for BLs/subsidiaries , so my count should change bsed on BLs/subsidiaries slicer selection for example for below  BLs/subsidiaries as "One" I have total row count as 14 , if i change slicer to another selection my row count also changes.

Can someone help here.Thanks.

 

 

 

weight =100/14   
Total row count =14   
ItemSourceBLs/subsidiariesWeight
Asset InitiativesOne7.142857
Overall BLOne7.142857
Energy BLOne7.142857
Availability BLOne7.142857
RE InitiativesOne7.142857
 EmissionsBLOne7.142857
ConversionInitiativesOne7.142857
Fuel  BLOne7.142857
Energy  BLOne7.142857
Reliability InitiativesOne7.142857
3E’sInitiativesOne7.142857
Reliability InitiativesOne7.142857
Thermal BLOne7.142857
Reliability InitiativesOne7.142857

8 Replies

  • Hi   binayjethwa 

    try to write a measure like this:

    Measure =
    VAR _count = 
    COUNTROWS(
        FILTER(
            ALL(TableName),
            TableName[Weight] = 14
        )
    )
    RETURN
    DIVIDE(_count, 100)
  • FreemanZ  here count of weight =14 is just given for reference, it will change based on slicer selection and its  dynamic. In above table there are 14 rows hence count is 14 , if there are 4 rows i should see  weight as 25% for each row.

    • FreemanZ's avatar
      FreemanZ
      Icon for Super User rankSuper User

      Hi binayjethwa 

       

      Not sure if i fully get you, then try 

      Measure =
      VAR _bl =SELECTEDVALUE(TableName[ BLs/subsidiaries])
      VAR _count = 
      COUNTROWS(
          FILTER(
              ALL(TableName),
              TableName[BLs/subsidiaries] = _bl
          )
      )
      RETURN
      DVIDE(100, _count)
      • binayjethwa's avatar
        binayjethwa
        Icon for Helper V rankHelper V

        FreemanZ  The above measure is working fine with single selection , but if i do multiple selections i see weight is calculated sepatately. even if i do multiple selections , for example 2 BL/subsidaries , it should take total count of selected BL/s and divide by 100 as a whole. can you please suggest how we can achieve this.

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi, binayjethwa 

     

    You can try the following methods.

    Measure = 
    Var _N1= CALCULATE(COUNT('Table'[BLs/subsidiaries]),ALLEXCEPT('Table','Table'[BLs/subsidiaries]))
    Return
    DIVIDE(100,_N1)

    Two is four rows.

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

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

     

      • v-zhangti's avatar
        v-zhangti
        Icon for Community Support rankCommunity Support

        Hi, binayjethwa 

         

        Based on the screenshots you provided, what do you expect the result to be?

         

        Best Regards,

        Community Support Team _Charlotte