Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

CREATE A RANGE FROM MEASURE

Hello I need some help plis

 

I have  this measure

CUMPLIMIENTO = CALCULATE(DIVIDE(CONSOLIDADO[RGU],[SUMmeta]))
the result  is the percentage of compliance.
 
NOW  I need get a range to know the lowest,medium and highest percentage of compliance and put it in a filter
 
 I try add a column whit these measures
Rangos = SWITCH(TRUE(),[CUMPLIMIENTO]< 0.50,"BAJO",[CUMPLIMIENTO]>=0.50 && [CUMPLIMIENTO]<0.80,"MEDIO",[CUMPLIMIENTO]>=0.80,"ALTO")
 
AND
 
Rango cumplimiento = IF('METAS POR AGENTE'[CUMPLIMIENTORGUAGE]<0.5,"BAJO",IF('METAS POR AGENTE'[CUMPLIMIENTORGUAGE]>=0.8,"ALTO","MEDIO"))
 
But none of them worked
 
example; I choose "BAJO", but the result in not correct.
 
I need add something more? I don´t know
 
Can someone help me plis.
 
 
  • You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hello,lbendlin ,thanks for your concern about this issue.

    Your answer is excellent!
    And I would like to share some additional solutions below.


    Hi,Anonymous.I am glad to help you.

    According to your description, you are trying to use measure in the process of creating a calculated column.
    In fact, as lbendlin mentioned, it is generally not recommended to refer to measure when creating calculated columns.
    This can lead to some problems related to the fact that they have different effective times.
    The time when measure takes effect is when there is an obvious environment for the calculation (putting the measure into a visual).
    This is when measure calculates the results.

    The calculate column is loaded when the report is refreshed and it takes up memory space, whereas the measure does not and the measure is a scalar value.
    I ran the following test

    This is my test data.

    I first created a measure, and created the first calculated column from this measure (which works fine)
    All the columns and measure data used in both dax codes are from the same table 'data_refreshTest'.
    No other table data is involved

    The first valid calculated column created


    The problem arises when I try to create another calculated column using another measure

     

    M_useOtherTableMeasure = 
    IF('data_refreshTest'[M_FilterTimeID]="small",1,2)

     

    The measure is dependent on a previously created measure, and the creation of a second calculated column has a circular dependency problem that prevents it from displaying properly.

    In fact, even though all measures in a report model are shared (they do not belong to a specific table), the problem is that the computed columns and measures have different computation logic, and it is not recommended to apply other measures when creating computed columns.
    But the problem is that the calculation logic of the calculated columns and measures are not the same, it is not recommended to create calculated columns when applying other measures, which has a greater risk:
    1. Easy to have circular dependencies and other problems
    2. The calculation logic that can be realized must be simple.
    3. metrics are computed in the filtering context, while computed columns are computed in the row context. This mixing may lead to computational inefficiencies.
    If you do need to refer to the metric in the calculated column, it is recommended that you try to optimize the formula to make the calculation logic of the measure used simple and to ensure that it does not have a disproportionate impact on performance. Typically, measures are better suited for dynamic calculations and aggregation in reports, while calculated columns are better suited for static calculations and data preprocessing.
    Instead of [Rangos] (the metrics you use in your calculated columns), I recommend creating calculated columns that accomplish the same thing.
    Their computational environments can be kept as identical as possible, minimizing performance issues and error reporting.
    Here's the link in question, hopefully it helps
    URL:
    Solved: Using a Measure in a Calculated Column - Microsoft Fabric Community

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

    Best Regards,

    Carson Jian

2 Replies

  • You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello,lbendlin ,thanks for your concern about this issue.

    Your answer is excellent!
    And I would like to share some additional solutions below.


    Hi,Anonymous.I am glad to help you.

    According to your description, you are trying to use measure in the process of creating a calculated column.
    In fact, as lbendlin mentioned, it is generally not recommended to refer to measure when creating calculated columns.
    This can lead to some problems related to the fact that they have different effective times.
    The time when measure takes effect is when there is an obvious environment for the calculation (putting the measure into a visual).
    This is when measure calculates the results.

    The calculate column is loaded when the report is refreshed and it takes up memory space, whereas the measure does not and the measure is a scalar value.
    I ran the following test

    This is my test data.

    I first created a measure, and created the first calculated column from this measure (which works fine)
    All the columns and measure data used in both dax codes are from the same table 'data_refreshTest'.
    No other table data is involved

    The first valid calculated column created


    The problem arises when I try to create another calculated column using another measure

     

    M_useOtherTableMeasure = 
    IF('data_refreshTest'[M_FilterTimeID]="small",1,2)

     

    The measure is dependent on a previously created measure, and the creation of a second calculated column has a circular dependency problem that prevents it from displaying properly.

    In fact, even though all measures in a report model are shared (they do not belong to a specific table), the problem is that the computed columns and measures have different computation logic, and it is not recommended to apply other measures when creating computed columns.
    But the problem is that the calculation logic of the calculated columns and measures are not the same, it is not recommended to create calculated columns when applying other measures, which has a greater risk:
    1. Easy to have circular dependencies and other problems
    2. The calculation logic that can be realized must be simple.
    3. metrics are computed in the filtering context, while computed columns are computed in the row context. This mixing may lead to computational inefficiencies.
    If you do need to refer to the metric in the calculated column, it is recommended that you try to optimize the formula to make the calculation logic of the measure used simple and to ensure that it does not have a disproportionate impact on performance. Typically, measures are better suited for dynamic calculations and aggregation in reports, while calculated columns are better suited for static calculations and data preprocessing.
    Instead of [Rangos] (the metrics you use in your calculated columns), I recommend creating calculated columns that accomplish the same thing.
    Their computational environments can be kept as identical as possible, minimizing performance issues and error reporting.
    Here's the link in question, hopefully it helps
    URL:
    Solved: Using a Measure in a Calculated Column - Microsoft Fabric Community

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

    Best Regards,

    Carson Jian