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
VulcanPromance
Helper II
Helper II

Calculation within a table visual

Hi.

 

Lets say I have a table with products called Products. It contains a product name, a category name and a price.
In the visual I want to show Categories, Products (there can be several under each category) and price, but in the same visual I also want to calculate Markup 3%, and Transfer Pricing 5% and 12% Tax witholding based on various variable.. Like markup for all categories, transfer pricing for just a few, and tax witholding for just 1. Is this possible? Its quite easy in excel, but Power Bi has me baffled on this thing that seems so easy.

 

 

Table 1.png

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@VulcanPromance 

 

Thank you for providing the sample data (I see the criteria differ from your original post).

Here is how I have gone about this.

1) Create a table including the categories and rows you will be using in your visual.

Firstly, reference a new table to the data table and delete all columns except Category and product.

Next create a new table ("Enter Data") with two columns: Category and Product and type in the values for your extra rows in your visual:

Extra Rows.JPG

Now Append these two tables to create a new table (I've called it "Visual Rows") including all categories and products as in:

Visual Rows.JPG

 Load into the model, and make sure there are no relationships between your tables:Model.JPG

 

2) create the calculation measures:

 

Sum of Cost = SUM(Data[Cost])
Markup 3% = CALCULATE([Sum of Cost] * 0,03)
Tranfer Pricing 5% = CALCULATE([Sum of Cost] * 0,05;
                        FILTER('Data';
                            'Data'[Product] = "A" || 'Data'[Product] = "B" ))
Withold Tax = CALCULATE([Sum of Cost] * 0,12;
                FILTER('Data';
                'Data'[Product] = "A"))

 

 

3) now you need to create new measures to adapt to the row structure of the table/visual:

 

Sum of cost (visual) = CALCULATE([Sum of Cost]; TREATAS(VALUES('Visual rows'[Product]); 'Data'[Product]))
Cost (calc) = SWITCH(TRUE();
        SELECTEDVALUE('Visual rows'[Product]) = "Markup 3%"; [Markup 3%];
        SELECTEDVALUE('Visual rows'[Product]) = "Transfer Pricing 5%"; [Tranfer Pricing 5%];
         SELECTEDVALUE('Visual rows'[Product]) = "Withhold Tax 12%"; [Withold Tax];
         [Sum of cost (visual)])
Cost (for Visual) = 
SUMX(SUMMARIZE('Visual rows'; 'Visual rows'[Product]; "Cost1"; [Cost (calc)]); [Cost1])

 

4) you can now create your visual using the Category and Product from your new table (in my case table "Visual Rows") and the last measure created [Cost (for Visual)].

 

to get this:

result.JPG

 

and here is the PBIX file if you're interested:

Row structured visual 

 

EDIT: Apologies since I live in a land (local settings) where;

- the decimal separator is a " , " instead of a " . "

- the thousands separator is a " . " instead of a " , "

- the separator in measures is a " ; " instead of a " , "





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

@VulcanPromance 

 

Thank you for providing the sample data (I see the criteria differ from your original post).

Here is how I have gone about this.

1) Create a table including the categories and rows you will be using in your visual.

Firstly, reference a new table to the data table and delete all columns except Category and product.

Next create a new table ("Enter Data") with two columns: Category and Product and type in the values for your extra rows in your visual:

Extra Rows.JPG

Now Append these two tables to create a new table (I've called it "Visual Rows") including all categories and products as in:

Visual Rows.JPG

 Load into the model, and make sure there are no relationships between your tables:Model.JPG

 

2) create the calculation measures:

 

Sum of Cost = SUM(Data[Cost])
Markup 3% = CALCULATE([Sum of Cost] * 0,03)
Tranfer Pricing 5% = CALCULATE([Sum of Cost] * 0,05;
                        FILTER('Data';
                            'Data'[Product] = "A" || 'Data'[Product] = "B" ))
Withold Tax = CALCULATE([Sum of Cost] * 0,12;
                FILTER('Data';
                'Data'[Product] = "A"))

 

 

3) now you need to create new measures to adapt to the row structure of the table/visual:

 

Sum of cost (visual) = CALCULATE([Sum of Cost]; TREATAS(VALUES('Visual rows'[Product]); 'Data'[Product]))
Cost (calc) = SWITCH(TRUE();
        SELECTEDVALUE('Visual rows'[Product]) = "Markup 3%"; [Markup 3%];
        SELECTEDVALUE('Visual rows'[Product]) = "Transfer Pricing 5%"; [Tranfer Pricing 5%];
         SELECTEDVALUE('Visual rows'[Product]) = "Withhold Tax 12%"; [Withold Tax];
         [Sum of cost (visual)])
Cost (for Visual) = 
SUMX(SUMMARIZE('Visual rows'; 'Visual rows'[Product]; "Cost1"; [Cost (calc)]); [Cost1])

 

4) you can now create your visual using the Category and Product from your new table (in my case table "Visual Rows") and the last measure created [Cost (for Visual)].

 

to get this:

result.JPG

 

and here is the PBIX file if you're interested:

Row structured visual 

 

EDIT: Apologies since I live in a land (local settings) where;

- the decimal separator is a " , " instead of a " . "

- the thousands separator is a " . " instead of a " , "

- the separator in measures is a " ; " instead of a " , "





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






This is simply brilliant. I wish I had this knowledge of Power Bi..

@VulcanPromance 

 

Thanks for your comment. I very much appreciate it! 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

@VulcanPromance 

 

Can you please provide a table with sample data? (dummy data if confidential)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.