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
Dippnsidways
Frequent Visitor

Percent of Total

Hi All,

 

I am not sure have I am doing wrong and would like some guidance. 

I would like the calculate the percent of theCode as a total.

Here is my data set:

t1.JPG

 

 

 

 

 

 

 

 

 

 

 

 

I want to create another column (table below) where it takes theCode quantity, divides it with theTotal quantity of all codes for that day, and that column value is a percent. 

 

I hope this makes sense.

When I try to type a formula it returns infiniti for codes.

Maybe I'm making a small typo

Thanks!

 

yearMonthDay theCodequantity% per Code
2020January2108853= 8853 / (8853 + 300 + 187 + 58)
2020January21131300= 300 / (8853 + 300 + 187 + 58)
2020January21133187= 187 / (8853 + 300 + 187 + 58)
2020January215158= 58 / (8853 + 300 + 187 + 58)
2020January2208921= 8921 / (8921 + 490 + 277 + 92 + 2)
2020January22131490= 490 / (8921 + 490 + 277 + 92 + 2)
2020January22133277= 277 / (8921 + 490 + 277 + 92 + 2)
2020January225192= 92 / (8921 + 490 + 277 + 92 + 2)
2020January22772= 2 / (8921 + 490 + 277 + 92 + 2)
2020January2308773= 8773 / (8773 + 810 + 338 + 3 + 283)
2020January23131810= 810 / (8773 + 810 + 338 + 3 + 283)
2020January23133338= 338 / (8773 + 810 + 338 + 3 + 283)
2020January2323= 3 / (8773 + 810 + 338 + 3 + 283)
2020January2351283= 283 / (8773 + 810 + 338 + 3 + 283)
 
1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Dippnsidways 

 

You may create a measure as follows.

 

% per Code = 
DIVIDE(
    SUM('Table'[quantity]),
    CALCULATE(
        SUM('Table'[quantity]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Date] = MAX('Table'[Date])
        )
    )
)

 

 

Result:

e1.png

 

To format the measure, you may click the 'Modeling' ribbon and then the '%' icon.

e2.png

 

Best Regards

Allan

 

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

View solution in original post

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @Dippnsidways 

 

You may create a measure as follows.

 

% per Code = 
DIVIDE(
    SUM('Table'[quantity]),
    CALCULATE(
        SUM('Table'[quantity]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Date] = MAX('Table'[Date])
        )
    )
)

 

 

Result:

e1.png

 

To format the measure, you may click the 'Modeling' ribbon and then the '%' icon.

e2.png

 

Best Regards

Allan

 

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

amitchandak
Super User
Super User

Assuming you have date in your table and that date is joined with a calendar date dimension. Please try following

% day = divide(SUM(Table[Quantity]),CALCULATE(SUM(Table[Quantity]),ALLEXCEPT(Date,Date[Date])))

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

amitchandak,

 

Thanks for your suggestion.

Sorry for not including the name of my table.

I've tried your suggestion but did not yield the result I was looking for.

I am to guess I did not have have a date calendar and marked as the date in model view.

I will follow the links you have provided and build on that.

Thanks!

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.