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
nj-matt
Helper I
Helper I

Add measures with totals for data not in the selection

I have a dataset that look something like this -->

 

CustomerClass of TradeSalesProfit $Profit MarginProfit Margin COTProfit Margin Nat'l
Retailer AGrocery1105045%38%36%
Retailer BGrocery1003030%38%36%
       
Retailer CMass Merch1506040%40%36%
       
Retailer DDrug Store1002525%28%36%
Retailer EDrug Store802835%28%36%

 

I want to create 2 new measures to capture the calculated profit margin of the associated class of trade and total.

 

So for example if I choose Retailer B si should see the margin for that dataset but also the calculated margin for total Grocery and total all customers.

 

There may also be an instance where a user may select both Retail B (Grocery) and Retailer E (Drug Store) in which the COT Profit Margin should be total Grocery and Drug Store combined.

 

How do I do this in Dax?

3 REPLIES 3
edhans
Super User
Super User

is this what you need @nj-matt 

edhans_0-1617237200492.png

If I select Mass Merc in the slicer, the total GP% will still be 11.11 % since it is a percent of the total sales - 540/60

The measure code is:

GP% of Total = 
VAR varTotalSales = 
    CALCULATE(
        SUM('DataTable'[Sales]),
        REMOVEFILTERS('DataTable')
    )
VAR varProfit = SUM('DataTable'[Profit $])
RETURN
DIVIDE(
    varProfit,
    varTotalSales,
    0
)

If that isn't what you want, please provide expected results and the formula you are using to get that result.

 

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thanks, but no - I Am not looking for a % of total sales - the new measures are really just a reference.

 

So for example, if I choose a drug store retailer - I want to see how the profit margin of that retailer compares to the profit margin of all retailers in the same class of trade. 

I'll repeat this info. Perhaps someone else can read what you mean and provide measures and guess right. I need examples of data and output.

 

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.

Top Solution Authors