Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Set another column to "flag" if the specific value exists on the same day

Hi,

 

I want to set the new column to "flag" if there is a word "yes" exists in another column on the same day.

 

Example:

 

Date        | Check   | Flag

1/1/21     | no        | flag

1/1/21     | no        | flag

1/1/21     | yes       | flag

1/2/21     | no        | no

1/2/21     | no        | no

1/3/21     | yes       | flag

1/3/21     | no        | flag

 

Flag column is my desired column. I know there's an easy way to achieve this but im losta bit

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I have found a way to complete this;

 

New = 
VAR dateselection = Sheet1[Date]
RETURN
    IF (
        "yes"
            IN SELECTCOLUMNS (
                FILTER (
                    ALL ( Sheet1[Date], Sheet1[Check] ),
                    Sheet1[Date] = dateselection
                ),
                "yes", Sheet1[Check]
            ),
        "flag",
        "no"
    )

 let me know if there's a better solution for this. Thank you! 

View solution in original post

2 REPLIES 2
tackytechtom
Super User
Super User

Hi @Anonymous ,

 

Here a solution in Power Query.

tackytechtom_0-1680582931351.png

 

 

 

Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACElHaW8fKVYHSLEKlOLUQWNsCjEJmaMTbMxVGEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Check = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Check", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Check] = "yes")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Date"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Date"}, #"Grouped Rows", {"Date"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Count"}, {"Grouped Rows.Count"}),
    #"Replace Values" = Table.ReplaceValue(#"Expanded Grouped Rows",each [Grouped Rows.Count],each if [Grouped Rows.Count] <> null then "flag" else "no",Replacer.ReplaceValue,{"Grouped Rows.Count"})

in
    #"Replace Values"

 

When you do that, all necessary steps should appear on the right. You can browse through them to understand what has been happening.

 

Let me know if this was what you were after. If you need a solution in DAX, I can look into this, too. 

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Anonymous
Not applicable

I have found a way to complete this;

 

New = 
VAR dateselection = Sheet1[Date]
RETURN
    IF (
        "yes"
            IN SELECTCOLUMNS (
                FILTER (
                    ALL ( Sheet1[Date], Sheet1[Check] ),
                    Sheet1[Date] = dateselection
                ),
                "yes", Sheet1[Check]
            ),
        "flag",
        "no"
    )

 let me know if there's a better solution for this. Thank you! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.