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
c5966
Helper I
Helper I

Calculated field with matrix

I need some support in calculated field in matrix table. Any help is much appreciated.

 

I have 2 columns 

CLASS_CONF and Change_class (which has 2 seperate values ClassChange and NoClassChange).

 

Original Table:

Original.png

 

I need to have a calculated column as below.

 

 

Matrix and red column is expected column: 

Expected.png

 

Thank you

c5966

1 ACCEPTED SOLUTION

Thank you for your help

 

I understood how to do this, first I need to group my class confidence and then use your divide function.

 

Accuracy = CALCULATE(divide(sum('table'[NoClassChange]), sum('table'[ClassChange])+sum('table'[NoClassChange])), fILTER(ALL('table'), 'table'[MEDTR_FRONT_VDAC_CLASS_CONF] = EARLIER('table'[MEDTR_FRONT_VDAC_CLASS_CONF])))

View solution in original post

8 REPLIES 8
Nathaniel_C
Super User
Super User

Hi @c5966 ,

If I understand that you are looking for a Dax formula, try Accuracy = Divide([No Class Change], [Class Change] + [No Class Change]). For the first line in your matrix, you would have the result below. 

If this solves your issue, please mark this as the solution. Kudos are nice too!

Nathaniel

No Class Change.PNG

 





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

Proud to be a Super User!




Appreciate your help.
 
Accuracy = Divide([NoClassChange],[ClassChange]+[NoClassChange])
 
This DAX formula did not give expected output ,please see below screenshot.
123.png
 
I would really appreciate any help on this topic.
 
Thank you.
 
 

@c5966 

My table with measure just make sure it is formatted for percentage

per.PNGd

 

If this solves your issue, please mark this as the solution. Kudos are nice too!

Nathaniel





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

Proud to be a Super User!




Also my NoClassChange column is calculated column:

it has one and 0 values

 

NoClassChange = if(export_lbj_8753[Change_Class] = "NoClassChange", 1,0)
ClassChange = if(export_lbj_8753[Change_Class] = "ClassChange",1,0)
 
how do we create divide formula on aggregated data? for this calculation.
 
 

thanks for the quick resonse. 

 

I have a questin, is it a caculated measure or calculated column which you have created below?

 

Thanks

 

@c5966 

You are right, calculated column is what it is as opposed to a measure.  Working on another project, and was to quick with my answer.

So did this answer your issue?

 





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

Proud to be a Super User!




@c5966 

Not sure what you are asking...should be the same with 1 or 0. Just reference the column name. Divide will return a blank unless you give it an alternative return for a divide by zero. See Dax Divide on the web:

 

Syntax

DAXCopy
DIVIDE(<numerator>, <denominator> [,<alternateresult>])  

Parameters

Term Definition
numeratorThe dividend or number to divide.
denominatorThe divisor or number to divide by.
alternateresult(Optional) The value returned when division by zero results in an error. When not provided, the default value is BLANK().

Return value

A decimal number.

Remarks

Alternate result on divide by 0 must be a constant.

 

If this answers you issue please mark as the solution.

 

Nathaniel





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

Proud to be a Super User!




Thank you for your help

 

I understood how to do this, first I need to group my class confidence and then use your divide function.

 

Accuracy = CALCULATE(divide(sum('table'[NoClassChange]), sum('table'[ClassChange])+sum('table'[NoClassChange])), fILTER(ALL('table'), 'table'[MEDTR_FRONT_VDAC_CLASS_CONF] = EARLIER('table'[MEDTR_FRONT_VDAC_CLASS_CONF])))

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.