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
NumbersAndStuff
New Member

DAX to Subtract a row from the row total to get variance

Hi,

 

assuming my data is summed in a matrix as follows:

 

columnA

1

2

3

4

-----

10

 

Question:

how do I subtract the values from the total to determine variance of column A's total into a new columnB 

 

ie:

ColumnA. | columnB

1.                       9

2.                       8

3.                       7

4.                       6

----------------------

10.                    30

 

4 REPLIES 4
VishalJhaveri
Resolver III
Resolver III

I created the table "testTable" with a single column, "A".
 

Plotted this column in the matrix visual.

VishalJhaveri_0-1671710889773.png

 



Measure to build column B =
CALCULATE(
    SUM(TestTable[A]),
    ALL(TestTable[A])
    )
    -
    CALCULATE(SUM(TestTable[A]))

Plotted this measure in the matrix table.

VishalJhaveri_0-1671714958533.png

 

I hope this solution helps.

Thank you.



Hi, thanks for the help! I'm still having some issues and want to clarify it a little more. ColumnA is a measure which is:

 

Avg = calculate(sum('dw factsalesorders'[Sales])/calculate(sum('dw factsalesorders'[qty])))

 

when I try to do this it's not working correctly:

 

vari=calculate(sum('dw. Factsalesorders'[sales])/calculate(sum('dw factsalesorders'[qty])),all('dw factsalesorders'))-calculate(sum('dw factsalesorders'[sales])/calculate(sum('dw factsalesorders'[qty])))

 

it changes all values in the matrix and isn't correct...what am I doing wrong :)?

364EF7AE-A8EC-49E1-86F2-BF66C044C0C5.jpeg

Can you please share the file using ONEDRIVE Link? @NumbersAndStuff 

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.