cancel
Showing results for
Did you mean:
c5966 Regular Visitor

## 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: I need to have a calculated column as below.

Matrix and red column is expected column: Thank you

c5966

1 ACCEPTED SOLUTION

Accepted Solutions
c5966 Regular Visitor

## Re: Calculated field with matrix

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])))
8 REPLIES 8
Nathaniel_C Super Contributor

## Re: Calculated field with matrix

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 c5966 Regular Visitor

## Re: Calculated field with matrix

Accuracy = Divide([NoClassChange],[ClassChange]+[NoClassChange])

This DAX formula did not give expected output ,please see below screenshot. I would really appreciate any help on this topic.

Thank you.

Nathaniel_C Super Contributor

## Re: Calculated field with matrix

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

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

Nathaniel

c5966 Regular Visitor

## Re: Calculated field with matrix

thanks for the quick resonse.

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

Thanks

c5966 Regular Visitor

## Re: Calculated field with matrix

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.

Nathaniel_C Super Contributor

## Re: Calculated field with matrix

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.

Nathaniel_C Super Contributor

## Re: Calculated field with matrix

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
 numerator The dividend or number to divide. denominator The 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.

Nathaniel

c5966 Regular Visitor

## Re: Calculated field with matrix

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])))

Announcements Learn the answers to some of the questions asked during the Amanda Triple A event. #### October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.  #### Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI. Top Kudoed Authors
Users Online
Currently online: 127 members 1,293 guests
Recent signins:
• ghine2 • Kogikoski • BileMG • fvicente • evilchesg • Cfarinha • fvicente • dntnmatt • cyberpowerbi • JasonYeung • William_Emory • rajukarkee • MikeR-DTS 