Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Help with Flag Column

Hi All,

 

I have requirement to create a P_Flag column and use in slicer.

When any one C_code associated with P_Codes have C_flag as Y then whole P_Flag should be assigned Y. Please find the O/P required below. 

 

Table1

P_CodeC_CodeAmt
8G131860
8G145830
8G131480
G5475040
G5454720
G5445850
TY715910

 

Table2

C_CodeC_Flag
318Y
458N
314N
750N
547N
159Y

 

Output

 

P_CodeC_CodeAmtO/P P_Flag
8G131860Y
8G145830Y
8G131480Y
G5475040N
G5454720N
G5445850N
TY715910Y

 

 

Thank you in advance

 

  • MFelix's avatar
    MFelix
    3 years ago

    Hi,

     

    For this you need to create a disconnected table with the filter to be used in this case Y/N.

     

    The create the following measure:

    Flag_MEasure_filter = IF([P FLag Measure] in DISTINCT('Flag Filter'[Flag filter]), 1)

    Use this measure to filter the table and the column of the disconnected table to use has slicer result below and in attach file:

     

     

     

16 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi All,

     

    Please let me know if the requirement is posiible at all I have been struggling with this for some time.

     

    Thank you

  • Hi Anonymous ,

     

    Try the following code:

     

    Flag = 
    VAR P_CodeSelection = Table1[P_Code]
    VAR temp_table =
        SUMMARIZE (
            ADDCOLUMNS (
                FILTER ( DISTINCT(Table1[P_Code]), [P_Code] = P_CodeSelection ),
                "FlagValue", RELATED ( Table2[C_Flag] )
            ),
            [FlagValue]
        )
    RETURN
        IF (
            CONTAINSSTRING ( CONCATENATEX ( temp_table, [FlagValue] ), "Y" ) = TRUE (),
            "Y",
            "N"
        )

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi MFelix ,

       

      Thank you so much for the reply.

       

      I see the new column is bringing the flag into the Table1 but I would like to add as column is bring new column and assign Y

      even if one C_code has Y then assing Y for the whole P_code as below

       

      I made a code as below which is working fine but not considering when date selected 

       

      Step1: created measure in Table2

      Flag Measure = IF(MAX(Table2[Flag]) = "Y",1,0)

      Step2: created column in Table1

      Flag_new column =
      var __pcode = Table1[P_Code]
      var __max   = maxx(FILTER(ALL(Table1),Table1[P_Code] = __pcode),[Flag Measure])
      return
      IF(__max = 1,"Y","N")
       
      Sorry missed date column date is coming from different table though but the please check below data sample below

       

      P_CodeC_CodeAmtDate
      8G13186011/15/2022
      8G14583011/15/2022
      8G13148011/15/2022
      G547504011/15/2022
      G545472011/15/2022
      G544585011/15/2022
      TY71591011/15/2022
      8G14583011/14/2022
      8G13148011/14/2022
      G547504011/14/2022
      G545472011/14/2022
      G544585011/14/2022
      TY71591011/14/2022

       

      C_CodeFlag
      318Y
      458N
      314N
      750N
      547N
      159Y

       

      Please suggest and help with column if possible to achieve

       

      • MFelix's avatar
        MFelix
        Super User

        Hi Anonymous ,

         

        I got lost about what is your need.

         

        You want to have a dynamic calculation of the Y/N based on the date selected?

        If that is the case you need a measure and not a column because columns are static calculations, I also need to see how you have the connection with the date values.