Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Khaoula_Farissi
Frequent Visitor

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
1 ACCEPTED SOLUTION

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:

edhans_1-1608339949874.png

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:

 
 

2020-12-18 17_09_12-20201218 - Percentages for different data - Power BI Desktop.png

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.

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
Khaoula_Farissi
Frequent Visitor

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

Capture1.PNG

count(BrandMonth2)/total(BrandMonth2)*100

Capture2.PNG

i want to get :

Capture3.PNG

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:

edhans_1-1608339949874.png

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:

 
 

2020-12-18 17_09_12-20201218 - Percentages for different data - Power BI Desktop.png

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.

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

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?



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors