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
jonlloyd
Frequent Visitor

Calculating differences

I have recently starting using Power BI in my school to analyse data. One thing I am trying to user it to replace is showing differences between types of students on certain KPI's

For example I have a table that shows male and female showing various KPI's and I want to create a difference column at the end

The KPI's are calculated measures.

KPIMaleFemaleDifference
%4+Ebacc45.56%68.83%-23.37%
%5+Ebacc23.33%46.75%-23.42%
 

I also want to be able to change the student type so that one table might show gender, another Special Education Needs types, another ethnicity etc.

 

Any help for a complete Power BI beginner will be appreciated.

 

1 ACCEPTED SOLUTION

Hi @jonlloyd ,

 

You can refer to this post. This will help you solve the problem

 

Best Regards,

Liang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickl

View solution in original post

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

Hi @jonlloyd ,

 

Based on your description, you want to calculate a new measure based on KPI. You can learn about the basic features of DAX, as well as the "DIVIDE" function and the "VAR" function.

You can refer to this sample of DAX:

Measure =
var sum_stu = MAX('Table'[Column1])+MAX('Table'[Column2])
var cur_count = MAX('Table'[Column1])
return DIVIDE(cur_count,sum_stu)

 

Best Regards,

Liang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

hi @V-lianl-msft 

 

Thank you for the info, but I can't get the formula to work. Do I need to replace the 'Table' [column1] part with my own data tables?

On my data tables the information for column 1 and 2 is stored in the same column in my data table so does that make a difference?

 

sorry for my stupidity I'm still trying to figure out DAX formulas. 

 

 

Hi @jonlloyd ,

 

The formula I gave you is just a sample. You need to use your own table and column names.  Or you can provide your sample data and expected result. So we can help you solve the problem more effectively

 

Best Regards,

Liang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

hi @V-lianl-msft 

 

Unfortunately, I can't provide an example of my data as its all live student data with too much personal information on it to share. Is there anything else I can provide you that maybe of use to help me with my problem?

 

The KPI's are all calculated measures, and the gender of the student is in the same column with a row for each student in the table but is acting as a filter on a matrix table. I want the difference value to appear as an additional column Hopefully the screenshot below may helppowerbi.png

 

Hi @jonlloyd ,

 

You can refer to this post. This will help you solve the problem

 

Best Regards,

Liang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickl

Greg_Deckler
Super User
Super User

Should just have to create a measure like:

 

Difference = [Measure1] - [Measure2]


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.