Forum Discussion

YMY's avatar
YMY
Regular Visitor
2 years ago

How to control computed columns by filtering changes in variables?

嗨,先生,我想按值过滤计算列,
其中 Values 是生成的列,单个表中共有 192 个值。现在我想使用以下公式计算 CONVERTME。筛选器使用 Values 来控制更改 ConvertMe 的设置。我可以这样做吗?有什么想法吗?谢谢
 
 

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi YMY ,

     

    Your idea is correct, but it seems that you should be using calculated columns. Calculated columns are static values added to the table and are calculated row by row when loading data. In contrast, measure is a dynamic value that changes based on what you view in the report, dynamically calculated in the context of the visual's filter. For more information about calculated columns and measures, please refer to the link: Understanding Measures vs Calculated Columns in Power BI (gorilla.bi).


    Therefore, this can be achieved using measure.

    Len_num = GENERATESERIES(1,MAX('Table'[Len_max]),1)
    Measure =
    VAR settings = SELECTEDVALUE(Len_num[Values])
    VAR ConvertMe = LEFT(
    RIGHT(MAX('Table'[Num]),LEN(MAX('Table'[Num])) - settings + 1),10)
    RETURN
    ConvertMe

     

    If your Current Period does not refer to this, please clarify in a follow-up reply.

     

    Best Regards,

    Clara Gong

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

    • YMY's avatar
      YMY
      Regular Visitor

      Hi, I'm glad you suggested it. I tried to do it, but“Values” as a filter still can't change the Values generated by ConvertMe dynamically. I'm sorry for not being clear at the beginning, but the first"解析12"is the computed column. 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi YMY ,

        As my reply above said, calculated columns are only calculated once when the table is first loaded or refreshed; this happens during the query. Therefore, calculated columns provide static values that do not change based on the filter context, making them more predictable and easier to understand in certain situations. In contrast, measure is a dynamic value, and these dynamic calculations change based on user actions such as filtering or slicing. This way, you can use the same measure for different visuals and data parts.

         

        So you can modify your calculated column to measure so that it changes with slicer selection. You can download the pbix file in my previous reply to view. The Column column is a calculated column. It will not change according to the selection of the slicer, while the measure column will change accordingly.

         

        If your Current Period does not refer to this, please clarify in a follow-up reply.

         

        Best Regards,

        Clara Gong

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