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
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
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.