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
Anonymous
Not applicable

Using Calculation with Slicer to use in Measure Calculation

I have the below table displayed in a report:

 

StateDiscounted SalesAll Sales
MA50200
SC100500
NY150300

 

I want the below [Discounted % of Total] column to be created below:

 

StateDiscounted SalesAll SalesDiscounted % of Total 
MA502005%
SC10050010%
NY15030015%
Total300100030%

 

The issue is everytime I create a new measure and try to calculate the All Sales Total (1000) it automatically groups it by ['State'], so using first row as an example, it displays 25% (50/200) intead of 5% (50/1000). I've tried CALCULATE, SWITCH, FILTER etc and all with the same result. 

 

Also in my report I have a date slicer by year, quarter and month which pulls from another [Date] Column, so when I apply the slicer by Date, I want table to update. So for example, in the first row, if I filtered by 2021, and the total number of sales was 500 instead of 1000, [Discounted % of Total] would update to 10% (50/500)

 

I've been able to find the total sales figure by using the MAX aggregation on [All Sales] bu then the number doensn't respond to the slicer. 

 

Thanks in advance!

 

 

 

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

pls try this

% of total = sum('Table'[Discounted Sales])/CALCULATE(sum('Table'[All Sales]),all('Table'))

1.png

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@Anonymous 

pls try this

% of total = sum('Table'[Discounted Sales])/CALCULATE(sum('Table'[All Sales]),all('Table'))

1.png

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




johnt75
Super User
Super User

Discounted % of total =
VAR currentValue =
    CALCULATE ( SUM ( 'Table'[Discounted Sales] ) )
VAR totalValue =
    CALCULATE ( SUM ( 'Table'[Discounted Sales] ), ALLSELECTED ( 'Table' ) )
RETURN
    DIVIDE ( currentValue, totalValue )

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.