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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PPalkowski
Helper II
Helper II

Column for Percentage

I have this simple table, how can I add a percentage column?

 

Meaning percentage of total hours for each Type

image.png

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @PPalkowski ,

 

We can create a calculated  table as below.

Table = 
SUMMARIZE (
    AllChanges,
    AllChanges[Type],
    "hours", DISTINCTCOUNT ( AllChanges[Number] ),
    "Percentage", FORMAT (
        DIVIDE (
            DISTINCTCOUNT ( AllChanges[Number] ),
            CALCULATE ( DISTINCTCOUNT ( AllChanges[Number] ), ALL ( AllChanges ) )
        ),
        "Percent"
    )
)

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @PPalkowski ,

 

We can create a calculated  table as below.

Table = 
SUMMARIZE (
    AllChanges,
    AllChanges[Type],
    "hours", DISTINCTCOUNT ( AllChanges[Number] ),
    "Percentage", FORMAT (
        DIVIDE (
            DISTINCTCOUNT ( AllChanges[Number] ),
            CALCULATE ( DISTINCTCOUNT ( AllChanges[Number] ), ALL ( AllChanges ) )
        ),
        "Percent"
    )
)

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Yikes, This works wonderful, but this is a total for Jan and Feb... I was going to add a slicer to drive monthly metrics, is there a way to create a relationship from this new table on AllChanges[Number]?

 

Thanks!!

 

edhans
Super User
Super User

Something similar to this:

 

Percentage =
VAR Numerator =
    SUM( Table[Hours] )
VAR Denomenator =
    CALCULATE(
        SUM( Table[Hours] ),
        REMOVEFILTERS( Table )
    )
VAR Result =
    DIVIDE(
        Numerator,
        Denomenator,
        0
    )
RETURN
    Result


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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.