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
BullGangGeneral
Regular Visitor

calculate percentages

how would you do a measure base on this scenario?

 

I have sales in all 50 states of America, each state has multiple sales, I drag individual sales amount onto a table, as well as the states, now i want to be able to calculate the the percentage each sale is of the total of that state. so lets say new york state has 2 sales, 5 and 10 dollars, and new jersey has 3 sales, 2, 3, 5 dollars each. i want to be able to show the 5 dollar sale in ny is 33% of the total for new york which is 15, and i also want to be able to show the 2 dollar sale for new jersey as 20% for new jersey because new jersey has total 10 dollar in sales.

 

any help is appreciated.

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @BullGangGeneral,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@BullGangGeneral , Try a measure

 

Divide(sum(Table[Sale]), calculate(sum(Table[Sales]), allselected()))

meh didn't work for me. i also tried allexcept, it just return percentage of grand total instead of sub total.

Hi @BullGangGeneral,

Any update for these? The measure expressions calculation is based on current row content levels.
For this scenario, it means you need to cancel the fields aggregate or add unique fields to prevent the summary on the row level. Then the expression can be calculated on each row instead of showing one row with a summarized value and the result 1 on the total level.

formula =
DIVIDE (
    SUM ( Table[Sales] ),
    CALCULATE (
        SUM ( Table[Sales] ),
        ALLSELECTED ( Table ),
        VALUES ( Table[State] )
    )
)

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.