cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sud Regular Visitor
Regular Visitor

Getting different result in measure and column

Hi,

 

  I am trying to use column instead of measure based on a value in swith/if statement but seems like Column value doesn't change.

  

  e.g.

   

   Measure 1 = SWITCH([Measure],"Hey",1,"Hello",2)  --Output is 1 when [Measure] = "Hey" and 2 when [Measure] = "Hello"
  
   Same thing in Column
  
  Column = SWITCH([Measure],"Hey",1,"Hello",2)  --Output is 1 when [Measure] = "Hey" and 1 when [Measure] = "Hello"

  What is the difference between them? Any help to know would be highly appriciated.
 
Thanks,
Sud
1 ACCEPTED SOLUTION

Accepted Solutions
v-danhe-msft Super Contributor
Super Contributor

Re: Getting different result in measure and column

Hi @Sud,

There is some difference between the calculated column and measure, the value of a calculated column is computed during data refresh and uses the current row as a context; it does not depend on user interaction in the report. A measure operates on aggregations of data defined by the current context, which depends on the filter applied in the report – such as slicer, rows, and columns selection in a pivot table, or axes and filters applied to a chart.

You could refer to below link:

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Re: Getting different result in measure and column

Hi Sud,
Calculated columns are under a row context and the measures are in a filter context.

 

Try using the CALCULATE function to change the context of the measure (Context Transition):

 

Column = CALCULATE (SWITCH ([Measure], "Hey", 1, "Hello", 2))

 

 

Tell us if it works for you.

 

v-danhe-msft Super Contributor
Super Contributor

Re: Getting different result in measure and column

Hi @Sud,

There is some difference between the calculated column and measure, the value of a calculated column is computed during data refresh and uses the current row as a context; it does not depend on user interaction in the report. A measure operates on aggregations of data defined by the current context, which depends on the filter applied in the report – such as slicer, rows, and columns selection in a pivot table, or axes and filters applied to a chart.

You could refer to below link:

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 66 members 1,309 guests
Please welcome our newest community members: