cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rber
Frequent Visitor

How to divide two rows in matrix based on certain condition with DAX

Hi all! I created a visual matrix which I want to divide some rows by a specific row and show the results through a measure. My matrix is shown below. I want to divide all the rows with ID_Perc = 1 by the single row with ID_Perc = 2

I have already managed to show only results from the rows I want, but unfortunately I can't divide properly. My measure is:

 

% Realizado =
VAR varValorPercentual = 100
VAR varPercentual = SELECTEDVALUE(DRE_Ordem[ID_Percentual])
RETURN

SWITCH(

TRUE();

varPercentual = 1 && NOT(ISINSCOPE(dPlanoDeContas[Nível 1 - PdC])); Abs(varValorPercentual);

BLANK())

 

And my visual matrix...

 

 Anotação 2020-04-27 144649.png

 

Thanks a lot!

Regards,

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

@rber ,

 

I'm confused on your description, could you share some sample data and clarify more details about your requirement?

 

Regards,

Jimmy Tao

camargos88
Community Champion
Community Champion

Hi @rber ,

 

I would guess something like:

 

VAR _total = CALCULATE(SUM('Table'[Valor]); FILTER(ALL('Table'); 'Table'[ID_PER] = 2))
var _valor = CALCULATE(SUM('Table'[Valor]); 'Table'[ID_PER] = 1)
return DIVIDE(_valor; _total; 0)

 

Ricardo

 



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

Proud to be a Super User!



Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.