Idea Flow
Models
Idea Flow
  • Welcome!
    • Why Models?
    • Why Principles?
  • Agility & Transformations
    • Intro to Agile
      • What Does Agile Mean?
      • What Is An Agile Mindset?
    • Intro to Transformation
      • Why Transform?
      • How Is The Transformation Done?
      • Who Transforms?
      • Which Areas or Functions Transform?
      • How Long Does A Transformation Take?
  • Agile Transformation (Idea Model)
    • Intro to IDEA
      • Leadership-Strip (Tanzaku)
      • Managing The Change
      • Metrics
      • Coaching Plan
        • Coaching Assessment
    • Initial Exposure
      • Training & Coaching
      • Assessment
    • Develop Basics
      • Training & Coaching
      • Assessment
    • Evolve & Reflect
      • Training & Coaching
      • Assessment
    • Accelerate & Kaizen
      • Training & Coaching
      • Assessment
  • Delivery Approach (Flow Model)
    • Intro to Flow
      • Flow of Work
      • Dev Sec Ops
    • Conceptualise
      • Purpose
      • Inputs
      • Process
      • Outputs
    • Commence
      • Purpose
      • Inputs
      • Process
      • Outputs
    • Construct
      • Purpose
      • Inputs
      • Process
      • Outputs
    • Confirm
      • Purpose
      • Inputs
      • Process
      • Outputs
    • Complete
      • Process
      • Outputs
    • Check
      • Process
  • Scrum, Kanban & Other Agile Frameworks
    • Double-Loop Scrum
    • Kanban
  • 3D Work-Breakdown
    • Intro to Work Breakdown
    • Direction
    • Discovery
    • Delivery
    • Flow & 3D Work-Breakdown
  • Roles & Responsibilities
    • Overview
      • Trust Circles
      • Enterprise View
    • Core Team Roles
      • Scrum Master / Iteration Manager
      • Product Owner
      • Developer
      • Tester
      • Business Analyst
      • Infrastructure
    • Extended Team Roles
      • Product Manager
      • Test Lead
      • Tech Lead
      • Subject Matter Expert (SME)
      • UX/UI Designer
      • Infrastructure Lead
      • Project Manager
      • Solution Architect
      • Delivery Manager
      • Change Analyst
    • Trusted Advisor Roles
      • Project Sponsor
      • Stakeholders
  • Topics
    • Prioritisation
    • Estimation
      • Estimation Overview
      • Epic Estimation
      • Initiative Estimation
    • Planning
      • Sprint / Iteration Planning
      • Release Planning
      • Quarterly Planning
      • Problem Statement
    • Ceremonies
      • Showcase
      • Scrum of Scrums
      • Stand-up
      • Retrospective
      • Elicitation
      • Elaboration
      • Acceptance Criteria (AC)
    • Artefacts
      • Tech Spike
      • Definition of Done
      • Social Contract
      • Personas
      • Lean Canvas
      • User Stories
    • Toolkit
      • Success Sliders
      • ICaRuS Scoring
      • Accountability Cards
    • Quality
      • Test Strategy
      • Test Plan
      • Quality Attribute Definitions
      • Test Type Definitions
      • Regression Test Suite Definitions
      • Defect Definitions
      • Defect Severity
      • Defect Priority
      • Agile Testing Quadrants
      • Risk-Based Testing
    • Templates
      • 3rd Party Handover Template
      • Audit Logs
    • Data
      • Information Management
    • Kanban
  • Agile Testing (4Aces Model)
    • Intro to Agile Testing
      • Test Principles
        • Test Automation Principles
      • Test Artefacts
      • Test Triangle
      • Agile Testing Quadrant
    • Arrange
    • Act
    • Assert
    • Annihilate
  • INCIDENT MANAGEMENT (TRACeR MODEL)
    • Intro to TRACeR
      • What is Incident Management
      • Incident Management Workflow
    • Triage
    • Review
    • Action
    • Check
    • Resolve
  • Change Management (3C Change Model)
    • Intro to 3C Change
      • What is Change?
      • What is Change Management?
      • 7Rs of Change Management
      • Model States
      • Implementation
    • Capture
      • Priority
      • Experience
      • Impact
      • Change Types
    • Consider
      • Risk
    • Conduct
      • Plan
        • Change Activities Matrix
      • Perform
        • Rollback or Roll-forward
      • Prove
        • Change Result/Status
  • Faciliation
    • Intro to Faciliation
      • Agile Facilitation
      • Planning and Running a Workshop
    • Meetings
      • Meeting Prep
    • Workshops
      • Quarterly Planning Workshop
      • Integrated Culture Workshop
    • Games
      • Dice Game
      • Battleships
      • Kanban Pizza Game
    • Icebreakers
      • Check Your Personal Thinking Style
  • Agile Coaching (A6 Model)
    • Intro to Coaching
    • Agree
    • Address
    • Assess
    • Align
    • Assign
    • Account
  • Agile Leadership
    • Intro to Agile Leadership
  • Strategy
    • What is Strategy?
    • What is Vision?
    • What is a Mission?
    • What are Values and Drivers?
    • Intent-based Outcomes
    • MunroMaps
  • OKRA
    • OKRS + ACTIONS = OKRA
      • Implementation
      • Cycle Cadence
    • Objectives
      • OKRs
    • Key Results
    • Actions
  • Agile Software Architecture (C4 Model)
    • Intro to Architecture
      • Role of the Architect
      • SOLID Principles
      • DRY Principle
      • Single Source of Truth (SSOT)
    • Context
      • Examples
    • Container
      • Examples
    • Component
      • Examples
    • Code
      • Examples
    • Patterns
      • Back-end for Front-end (BFF)
      • Event-Driven Microservices
  • Portfolio Management (PMO Practice Model)
    • Intro to Portfolio Management
      • Practices & Flow
      • Objectives
      • Types
      • Maturity Assessment
      • Setting Up
        • Charter
    • Demand Practice
    • Risk Practice
    • Performance Practice
      • Cost of Delay (CoD)
      • Metrics
    • Report Practice
    • Delivery Practice
    • Asset Practice
    • Change Practice
  • RAFT
    • RAFT Framework
  • Tools
    • Jira
      • Best Practice
      • Printing Physical Cards
    • Confluence
      • Best Practice
      • Example Confluence Layout
    • Power BI
      • Power Query M
    • Miro
      • Best Practice
  • FAQs
    • Frequently Asked Questions
    • Glossary of Terms
  • Thanks & Contributors
    • Thanks
    • License
Powered by GitBook
On this page
  • Useful Functions
  • fnGetDefaultHeaders
  • fnTypeTableColumns
  • fnSortTableColumns
  • fnExpandedColumnsFancy

Was this helpful?

  1. Tools
  2. Power BI

Power Query M

Useful Functions

fnGetDefaultHeaders

For cloud-based Jira Password is the API Key

() =>
[
    #"Content-Type" = "application/json",
    #"Authorization" = "Basic " & Binary.ToText(Text.ToBinary(Username & ":" & Password), 0),
    #"Retry-After" = "120"
]

fnTypeTableColumns

(tableToType as table, optional fieldsAndSchemaTypes as table, optional testCount as number) as table =>  
	List.Accumulate(Table.ColumnNames(tableToType), tableToType, (s, c) =>
  try
    let 
      schemaType = 
        if (fieldsAndSchemaTypes <> null) then
          try Table.SelectRows(fieldsAndSchemaTypes, each [name] = c)[#"schema type"]{0} otherwise null
        else 
          null,
      tests = List.Buffer(List.FirstN(Table.Column(s, c), if (testCount = null) then 100 else testCount)),
      fieldType = 
        if (schemaType = "string") then type text
        else if (schemaType = "number") then Int64.Type
        else null
    in
      if (fieldType <> null) then 
        Table.TransformColumnTypes(s, {{c, fieldType}})
      else  
        // Already has a defined column type
        if (Expression.Evaluate("type "& Table.SelectRows(Table.Schema(s), each [Name] = c){0}[Kind]) <> type any) then
          s
      
        // All null values then make text type, unless it has a schema type we can deal with 
        else if (List.MatchesAll(tests, each _ = null)) then
          try 
            if (schemaType = "date") then Table.TransformColumnTypes(s, {{c, type date}})            
            else if (schemaType = "datetime") then Table.TransformColumnTypes(s, {{c, type datetime}})
            else Table.TransformColumnTypes(s, {{c, type text}})
          otherwise 
            Table.TransformColumnTypes(s, {{c, type text}})  
        
        // Logic Types
        else if (List.MatchesAll(tests, each _ = null or (try _ = false or _ = true or Text.Upper(Text.From(_)) = "FALSE" or Text.Upper(Text.From(_)) = "TRUE" otherwise false))) then
          Table.TransformColumnTypes(s, {{c, type logical}})
        
        // Number Types
        else if (List.MatchesAll(tests, each _ = null or (try Number.Mod(Number.From(_), 1) otherwise -1) = 0)) then
          Table.TransformColumnTypes(s, {{c, Int64.Type}})
        else if (List.MatchesAll(tests, each _ = null or (try Number.Mod(Number.From(_) + 0.1, 1) otherwise -1) > 0)) then
          Table.TransformColumnTypes(s, {{c, type number}})
        
        // Date Types
        else if (List.MatchesAll(tests, each _ = null or (try Date.Year(Date.From(_)) > 2000 otherwise false))) then
          Table.TransformColumnTypes(s, {{c, type date}})
        else if (List.MatchesAll(tests, each _ = null or (try Date.Year(DateTime.Date(DateTime.From(_))) > 2000 otherwise false))) then
          Table.TransformColumnTypes(s, {{c, type datetime}})
        else if (List.MatchesAll(tests, each _ = null or (try Date.Year(DateTime.Date(DateTimeZone.RemoveZone(DateTimeZone.From(_)))) > 2000 otherwise false))) then
          //Table.TransformColumnTypes(s, {{c, type datetimezone}}) // datetimezone becomes text when surfaced to datamart - why M$ why!
          Table.TransformColumnTypes(Table.TransformColumnTypes(s, {{c, type datetimezone}}), {{c, type datetime}})

        // Else 
        else
          try 
            if (schemaType = "date") then Table.TransformColumnTypes(s, {{c, type date}})            
            else if (schemaType = "datetime") then Table.TransformColumnTypes(s, {{c, type datetime}})
            else Table.TransformColumnTypes(s, {{c, type text}})
          otherwise 
            Table.TransformColumnTypes(s, {{c, type text}})  
  otherwise 
    s
  )

fnSortTableColumns

(tableToSort as table) as table =>
  Table.ReorderColumns(tableToSort,
    let
      alphaSort = List.Buffer(List.Sort(Table.ColumnNames(tableToSort), Order.Ascending)),
      keyFixedLower = if List.Contains(alphaSort, "Key") then { "Key" } & List.RemoveItems(alphaSort, { "Key" }) else alphaSort,
      keyFixed = if List.Contains(keyFixedLower, "key") then { "key" } & List.RemoveItems(keyFixedLower, { "key" }) else keyFixedLower,
      idFixed = if List.Contains(keyFixed, "Id") then { "Id" } & List.RemoveItems(keyFixed, { "Id" }) else keyFixed,
      idFixedLower = if List.Contains(idFixed, "id") then { "id" } & List.RemoveItems(idFixed, { "id" }) else idFixed
    in
      idFixedLower,
    MissingField.Ignore
  )

fnExpandedColumnsFancy

(tableToFix as table, optional testCount as number) as table =>
    List.Accumulate(Table.ColumnNames(tableToFix), tableToFix, (s, c) =>
        let 
            tests = List.Buffer(List.FirstN(List.RemoveNulls(List.FirstN(Table.Column(s, c), if (testCount = null) then 5000 else testCount * 5)), if (testCount = null) then 1000 else testCount))
        in
            if (List.MatchesAny(tests, each try _ is record otherwise false)) then
                if (List.MatchesAny(tests, each try Record.HasFields(_, "id") and Record.HasFields(_, "name") otherwise false)) then
                    Table.ExpandRecordColumn(s, c, {"id", "name" }, { c & " Id", c})
                else if (List.MatchesAny(tests, each try Record.HasFields(_, "id") and Record.HasFields(_, "value") otherwise false)) then
                    Table.ExpandRecordColumn(s, c, {"id", "value" }, { c & " Id", c})
                else if (List.MatchesAny(tests, each try Record.HasFields(_, "key") and Record.HasFields(_, "name") otherwise false)) then
                    Table.ExpandRecordColumn(s, c, {"key", "name" }, { c & " Key", c})
                else 
                    s
            else 
                s
    )

Last updated 7 months ago

Was this helpful?