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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Mahmoud23
Regular Visitor

How to identify pattern that leads to a specific outcome??


If I have data from an experiment where the results are either red or green, I want to identify the most common pattern that leads to a specific outcome based on these results. For example, if the results are red three times in a row, the fourth result is green 80% of the time. I want to deduce these patterns and probabilities. How can I do this while ignoring all external factors, assuming that the data is just a single column containing the experiment's result—either red or green?

4 REPLIES 4
danextian
Super User
Super User

Hi @Mahmoud23 ,

You can use the Group By feature in Transform tab and add GroupKind.Local in the generated formula so the grouping is for every change in the column being grouped - not for every distinct value in that column.

= Table.Group(#"Changed Type", {"Value"}, {{"Grouped", each _, type table [Date=nullable date, Value=nullable text]}}, GroupKind.Local)

After grouping, you can then add an Index column to create a new group and add a new column to count the rows the in the tables in Grouped column.

danextian_0-1724069989758.png

This is the final result

danextian_1-1724070041107.png

Sample code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZdJLCoAwDIThu3QtmEwf1qV6jOL9r6FSkOoPXX1MwlDSWjCf7ydTClPYwjndpIH2TnGgo1MiZQ4WphZSZYkVu9ww6E4SKWK9J1Imsb2zvVcS28tITmJ7Rab492J7FRLbq3L9isFoJP79c0z6kQba3mP6pxJT+UvnBQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Value"}, {{"Grouped", each _, type table [Date=nullable date, Value=nullable text]}}, GroupKind.Local),
    #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Group", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "RowCount", each Table.RowCount([Grouped]),Int64.Type),
    #"Expanded Grouped" = Table.ExpandTableColumn(#"Added Custom", "Grouped", {"Date"}, {"Date"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Grouped",{"Group", "Value", "Date", "RowCount"})
in
    #"Reordered Columns"

 

Tbh, I am interested to see how this can be done using DAX but I am too occupied to think of a logic.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian Now that you mention it, Cthulhu could be an option to help identify patterns, it essentially identifies streaks in the data. Cthulhu - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for this @Greg_Deckler . Honestly, it would probably take me days to come up with a DAX solution...if I could. 😅





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Greg_Deckler
Community Champion
Community Champion

@Mahmoud23 Sounds like a case for machine learning. Not sure there is much pattern recognition built into Power BI beyond the Key Influencers visual which can be hit or miss. Any chance you have sample data?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors