Forum Discussion

Khaoula_Farissi's avatar
Khaoula_Farissi
Frequent Visitor
5 years ago
Solved

Measures

hello 

this is my data 

IdBrandMonth1BrandMonth2Vague
1AD3
2BD1
3CD1
4DC2
5AA3
6BB1
7CD2
8AC2
9BD2
10CD1
11DD1
12DC3
13DA2
14CB3
15AD1
16BC2
17DC2
18CA2
19AB3

i want to divide the percentage of BrandMonth1 by the percentage of BrandMonth2 and make Vague as columns and Brands as rows to get a table like this:

%BrandMonth1/%BrandMonth2123
A2.00 0.50
B0.00 0.50
C1.000.003.00
D1.000.251.00
  • edhans's avatar
    edhans
    5 years ago

    Hi Khaoula_Farissi - I am not sure I have the formula right, but you can change it. I modeled this properly, so bear with me as I explain.

    First, I created a dimension table with just the brands A, B, C, and D. So the model looks like this:

    Brand and BrandMonth1 are active, Brand and BrandMonth2 are inactive. That is why one is dotted vs solid.

     

    Then I created 3 measures:

     

    Vague Brand 1 = 
    DIVIDE(
        COUNTROWS('Table'),
        COUNTROWS(ALL('Table'))
    ) 
    --------------------------------------------------------------
    
    
    Vague Brand 2 = 
    CALCULATE(
        DIVIDE(
            COUNTROWS('Table'),
            COUNTROWS(ALL('Table'))
        ) , 
        USERELATIONSHIP(Brand[Brand], 'Table'[BrandMonth2])
    )
    -------------------------------------------------------------
    
    
    Vague Difference = [Vague Brand 1] - [Vague Brand 2]

     

    Vague Brand 1 counts the rows for each row in the table (so all A rows, then all B rows, etc.) and divides that by all of the rows in the table. That is the %.

     

    Vague Brand 2 does the same thing, but this time it uses the Brand/Brand Month 2 relationship. USERELATIONSHIP turns on that inactive relationship and turns off the Brand/Brand Month 1 for this measure only.

    The Vague Difference is simply the differnece between the 2 measures. The results:

     
     

    Here is my file so you can play with it as desired. If the math is wrong you can fix it or explain it better to me so I can assist.

     

     

3 Replies

  • edhans's avatar
    edhans
    Community Champion

    Percentage of what Khaoula_Farissi ? I don't see any values if you are saying [Vague] is your column headers. What is the math you want?

  • Sorry for the misunderstanding

    i want to calculate the count of every brand/total*100 this is how i do it in Excel:

    count(BrandMonth1)/total(BrandMonth1)*100

    count(BrandMonth2)/total(BrandMonth2)*100

    i want to get :

    • edhans's avatar
      edhans
      Community Champion

      Hi Khaoula_Farissi - I am not sure I have the formula right, but you can change it. I modeled this properly, so bear with me as I explain.

      First, I created a dimension table with just the brands A, B, C, and D. So the model looks like this:

      Brand and BrandMonth1 are active, Brand and BrandMonth2 are inactive. That is why one is dotted vs solid.

       

      Then I created 3 measures:

       

      Vague Brand 1 = 
      DIVIDE(
          COUNTROWS('Table'),
          COUNTROWS(ALL('Table'))
      ) 
      --------------------------------------------------------------
      
      
      Vague Brand 2 = 
      CALCULATE(
          DIVIDE(
              COUNTROWS('Table'),
              COUNTROWS(ALL('Table'))
          ) , 
          USERELATIONSHIP(Brand[Brand], 'Table'[BrandMonth2])
      )
      -------------------------------------------------------------
      
      
      Vague Difference = [Vague Brand 1] - [Vague Brand 2]

       

      Vague Brand 1 counts the rows for each row in the table (so all A rows, then all B rows, etc.) and divides that by all of the rows in the table. That is the %.

       

      Vague Brand 2 does the same thing, but this time it uses the Brand/Brand Month 2 relationship. USERELATIONSHIP turns on that inactive relationship and turns off the Brand/Brand Month 1 for this measure only.

      The Vague Difference is simply the differnece between the 2 measures. The results:

       
       

      Here is my file so you can play with it as desired. If the math is wrong you can fix it or explain it better to me so I can assist.