Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello PB'ers! Looking for some assistance here. Fairly new to Power BI but have a decent understanding for a beginner from usage and reverse engineering. May data is extensive 23 tables, largest having 4.1m rows.
Here is my sample data that represents what I'm trying to achieve. There are three service stations that generate sales including Oil Changes and Tire Rotations. For example simplicty, I've only added one fow for each month / service type, but in the actual data there are many rows per month / service. e.g. Store A / Jan / Oil Change / $50 x4.
I'm looking to Sum the revenue by service as a percentage of total Sales, and then Rank each store. E.g Store A in Jan, Oil Changes were 2.8% of Sales and Ranks 2nd behind Store B. Store C had no Oil Changes in Jan.
Store | Month | Sales |
A | Jan | 6999 |
A | Feb | 8025 |
A | Mar | 10255 |
B | Jan | 4900 |
B | Feb | 5000 |
B | Mar | 6025 |
C | Jan | 10000 |
C | Feb | 9950 |
C | Mar | 13000 |
Store | Month | Service | Revenue |
A | Jan | Oil Change | 200 |
A | Jan | Tire Rotation | 100 |
A | Mar | Oil Change | 300 |
B | Jan | Tire Rotation | 500 |
B | Feb | Oil Change | 250 |
B | Mar | Oil Change | 150 |
B | Mar | Tire Rotation | 100 |
C | Feb | Oil Change | 600 |
C | Mar | Oil Change | 1000 |
|
Thank you for your consideration,
This is a bit technical, but...
Start by creating an aggregate function. You can prototype this by starting with a table filtered to only one Month. Next you would group by both Store and Service and then add a aggregate of sum of Revenue. From here you can do a merge of the table with itself using the Service name as the join key. This will add an inner join column. By clicking on the right corner of the join column, you can choose to aggregate by sum of Revenue. This gives the total revenue per service. Getting the percentage is simply adding a column with dividing the revenue of a store by the total revenue of the service. To add rank, sort the table by percentile descending followed by adding an index column (note in case of tie, an arbitary decision is made as to what is higher).
Now that you have a prototype, enter the advanced editor and add to the start of the query:
(monthTable) =>
Delete the steps where you filter the table to a single month, and replace the following's step's reference to the step you deleted with monthTable. This will give you a function that applies the transform to any month. Change the name of this query to ApplyMonthlyStats.
Finally, in a new query, take your table, perform a group by and choose the count aggregate on revenue column. Then in the formula bar, replace "each List([revenue])" with "ApplyMonthlyStats". Now expand the resulting table column, and you are done.
Wow, thanks for this Artemus! I will see if I understand enough to put your text into action 🙏