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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RandomRaisin
Frequent Visitor

How to Calculate % of Online Sales when Total Sales are provided in different ways

Hi, I am new to Power BI and am trying to create a measure that calculates the percentage of sales that were done online, but each store provides their sales differently.  Some stores provide in store and online sales by transaction while other stores only provide online total and combined total sales (see below for example)

 

$ SalesChannelStore
50In StoreA
25OnlineA
70In StoreA
15OnlineB
80TotalB

 

How do I create a measure that sums up all online sales, then divides by total sales?

My trouble is calculating the total sales because I need the measure to combine all Store A sales, but only take Total from Store B and not add Online to Store B's total sales.

 

In this example, the measure would be:

Online / Total --> (25+15) / (50+25+70+80) = 40 / 225 = 17.8%

 

For context, there are a total of 16 stores, 7 of which provide online and total sales, while 9 stores provide In Store and Online Sales.

 

The farthest I've been able to get is this:

Online % Share of Total Sales =
calculate(sum('ALL RETAILERS'[$ Sales]),'ALL RETAILERS'[Channel]="Online") /
(
CALCULATE(sum('ALL RETAILERS'[$ Sales]),'ALL RETAILERS'[Channel]="In Store") +
CALCULATE(sum('ALL RETAILERS'[$ Sales]),'ALL RETAILERS'[Channel]="Total") +
if(CALCULATE(SUM('ALL RETAILERS'[$ Sales]),'ALL RETAILERS'[Channel]="Total")=0,CALCULATE(SUM('ALL RETAILERS'[$ Sales]),'ALL RETAILERS'[Channel]="Online"),0)
)
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@RandomRaisin try these two measures, you can always divide these into seperate measures:

 

Sum Sales = SUM ( [$ Sales] )


Total Sales = 
VAR __StoreWithTotalSales = 
CALCULATETABLE ( 
    VALUES ( 'Table'[Store] ),  
    'Table'[Channel] = "Total" 
) 
VAR __StoreThatHasOnlineSalesWithTotal = 
CALCULATE ( 
    [Sum Sales], 
    __StoreWithTotalSales,  
    'Table'[Channel] = "Online" 
) 
VAR __OnlineSales = 
CALCULATE (
    [Sum Sales],
    'Table'[Channel] = "Online" 
)
VAR __TotalSales = CALCULATE ( [Sum Sales], ALL ( 'Table' ) )
RETuRN DIVIDE ( __OnlineSales, __TotalSales - __StoreThatHasOnlineSalesWithTotal )

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@RandomRaisin try these two measures, you can always divide these into seperate measures:

 

Sum Sales = SUM ( [$ Sales] )


Total Sales = 
VAR __StoreWithTotalSales = 
CALCULATETABLE ( 
    VALUES ( 'Table'[Store] ),  
    'Table'[Channel] = "Total" 
) 
VAR __StoreThatHasOnlineSalesWithTotal = 
CALCULATE ( 
    [Sum Sales], 
    __StoreWithTotalSales,  
    'Table'[Channel] = "Online" 
) 
VAR __OnlineSales = 
CALCULATE (
    [Sum Sales],
    'Table'[Channel] = "Online" 
)
VAR __TotalSales = CALCULATE ( [Sum Sales], ALL ( 'Table' ) )
RETuRN DIVIDE ( __OnlineSales, __TotalSales - __StoreThatHasOnlineSalesWithTotal )

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you @parry2k! I changed the calculations a little bit, but using Variables with CALCULATETABLE worked perfectly for me!  Thank you so much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.