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
yaungwan
New Member

Percentage of category

Hi,

 

I am a first time user and i am struggling bad 😞

 

I am trying to work out a 'Measure' to find percentage of sum of 'base amount' for 'month' over the each genre.

 

For example below, the percentage of month 9 for animation is = 1925/(1928+1925+1910)=33%. 

 

Base Amount# OF MONTHTV FILMGENRE
1,918.004FILMCOMEDY
1,942.004FILMDRAMA
1,947.001FILMDRAMA
1,945.001FILMDRAMA
1,930.002FILMACTION
1,915.002FILMACTION
1,928.0010FILMANIMATION
1,925.009FILMANIMATION
1,910.0010FILMANIMATION

 

Thank you in advance for your help! 

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@yaungwan  Create these 3 Measure

Measure 1

Amount Measure = SUM('Table'[Base Amount])

Measure 2

Total Genre Amount = CALCULATE( [Amount Measure], ALLEXCEPT('Table', 'Table'[GENRE]) )

Measure 3

% Measure = DIVIDE ( [Amount Measure], [Total Genre Amount], 0 )

or you can create 1 that does it all

Measure Alternate

% Measure =
DIVIDE (
    SUM ( 'Table'[Base Amount] ),
    CALCULATE ( [Amount Measure], ALLEXCEPT ( 'Table', 'Table'[GENRE] ) ),
    0
)

The first approach is better for the long term - gives you more flexibility to use those Measure later

As Rob Collie says - Never write the same formula twice! Smiley Happy

% of Genre.png

Hope this helps! Smiley Happy

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Forgive me but I am super novice with DAX. I have a similar dataset but the DAX solution did seems to work out.

 

Here's my raw data set

 

SystemRunTime
A5
B7

 

I would like to $ diff the run time by System. Like this

SystemAB% Diff
RunTime5771%

 

Any guidance is appreciated

@Anonymous You may have resolved this by now but if not you could add a new column and insert the following calculation...% Diff=100/'Table'[B]*'Table'[A]

 

You'll need the data in the format of your second table (the one showing the %) for this to work.

Sean
Community Champion
Community Champion

@yaungwan  Create these 3 Measure

Measure 1

Amount Measure = SUM('Table'[Base Amount])

Measure 2

Total Genre Amount = CALCULATE( [Amount Measure], ALLEXCEPT('Table', 'Table'[GENRE]) )

Measure 3

% Measure = DIVIDE ( [Amount Measure], [Total Genre Amount], 0 )

or you can create 1 that does it all

Measure Alternate

% Measure =
DIVIDE (
    SUM ( 'Table'[Base Amount] ),
    CALCULATE ( [Amount Measure], ALLEXCEPT ( 'Table', 'Table'[GENRE] ) ),
    0
)

The first approach is better for the long term - gives you more flexibility to use those Measure later

As Rob Collie says - Never write the same formula twice! Smiley Happy

% of Genre.png

Hope this helps! Smiley Happy

 

 

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.