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

How to keep percentage when filtering

Hello,

 

I have de following data in a visualization:

 

Category Date Measure
A 02-2021 5,76%
B 02-2021 65,34%
C 02-2021 2,71%
D 02-2021 0,23%
E 02-2021 3,45%
F 02-2021 7,20%
G 02-2021 5,91%
H 02-2021 9,40%
TOTAL  100%

 

And if I filter categories A and B, I obtain the following:

 

Category Date Measure
A 02-2021 8,11%
B 02-2021 91,89%
TOTAL             100%

 

But I would like to have this data:

 

Category Date Measure
A 02-2021 5,76%
B 02-2021 65,34%
TOTAL   71,1%


How can I do this? I tried using ALL, ALLEXCEPT and ALLSELECTED but I wasn't able to get it.

 

Thank you!

1 ACCEPTED SOLUTION

try it

 

Measure = 
	VAR TotVolumen = SUM(table[VOLUMEN])
	VAR VolumenPart =
	            CALCULATE(
	            SUM(table[VOLUMEN]),
	            FILTER(
	                ALLSELECTED(table),
	                (table[Date] = MAX(table[Date])
	                )
	            ))
	VAR Result_for_ROW = DIVIDE(TotVolumen,VolumenPart)
VAR Result_for_TOTAL =CALCULATE(Result_for_ROW, ALL('Table'[Category]),All(table[Date]))
VAR Result = if(isinscope('Table'[Category]), Result_for_ROW ,Result_for_TOTAL )
RETURN Result

 

View solution in original post

7 REPLIES 7
SolomonovAnton
Responsive Resident
Responsive Resident

hello ! 

 

you should use ALL in your measure

 

for more details please write you measure which calculate %

Anonymous
Not applicable

Hello,

 

This is my measure:

Measure = 
	VAR TotVolumen = SUM(table[VOLUMEN])
	VAR VolumenPart =
	            CALCULATE(
	            SUM(table[VOLUMEN]),
	            FILTER(
	                ALLSELECTED(table),
	                (table[Date] = MAX(table[Date])
	                )
	            ))
	VAR Result = DIVIDE(TotVolumen,VolumenPart)
RETURN Result

try it

 

Measure = 
	VAR TotVolumen = SUM(table[VOLUMEN])
	VAR VolumenPart =
	            CALCULATE(
	            SUM(table[VOLUMEN]),
	            FILTER(
	                ALLSELECTED(table),
	                (table[Date] = MAX(table[Date])
	                )
	            ))
	VAR Result_for_ROW = DIVIDE(TotVolumen,VolumenPart)
VAR Result_for_TOTAL =CALCULATE(Result_for_ROW, ALL('Table'[Category]),All(table[Date]))
VAR Result = if(isinscope('Table'[Category]), Result_for_ROW ,Result_for_TOTAL )
RETURN Result

 

Anonymous
Not applicable

I tried but I get the same result.

If I answered at your question please mark topic as resolved 🙂

could you show your datamodel which include tables with Category, Date columns ?

Anonymous
Not applicable

Hello, 

it is solved with the ALL, I just needed to use a different tableof Category.

Thanks!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.