Forum Discussion
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_Code | C_Code | Amt |
| 8G1 | 318 | 60 |
| 8G1 | 458 | 30 |
| 8G1 | 314 | 80 |
| G54 | 750 | 40 |
| G54 | 547 | 20 |
| G54 | 458 | 50 |
| TY7 | 159 | 10 |
Table2
| C_Code | C_Flag |
| 318 | Y |
| 458 | N |
| 314 | N |
| 750 | N |
| 547 | N |
| 159 | Y |
Output
| P_Code | C_Code | Amt | O/P P_Flag |
| 8G1 | 318 | 60 | Y |
| 8G1 | 458 | 30 | Y |
| 8G1 | 314 | 80 | Y |
| G54 | 750 | 40 | N |
| G54 | 547 | 20 | N |
| G54 | 458 | 50 | N |
| TY7 | 159 | 10 | Y |
Thank you in advance
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
- AnonymousNot 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
- MFelixSuper User
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" )- AnonymousNot 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])returnIF(__max = 1,"Y","N")Sorry missed date column date is coming from different table though but the please check below data sample belowP_Code C_Code Amt Date 8G1 318 60 11/15/2022 8G1 458 30 11/15/2022 8G1 314 80 11/15/2022 G54 750 40 11/15/2022 G54 547 20 11/15/2022 G54 458 50 11/15/2022 TY7 159 10 11/15/2022 8G1 458 30 11/14/2022 8G1 314 80 11/14/2022 G54 750 40 11/14/2022 G54 547 20 11/14/2022 G54 458 50 11/14/2022 TY7 159 10 11/14/2022 C_Code Flag 318 Y 458 N 314 N 750 N 547 N 159 Y Please suggest and help with column if possible to achieve
- MFelixSuper 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.