skip to main content
Power BI
    • What is Power BI
    • Why Power BI
    • Customer stories
    • Data visuals
    • Security
    • Power BI Desktop
    • Power BI Pro
    • Power BI Premium
    • Power BI Mobile
    • Power BI Embedded
    • Power BI Report Server
  • Pricing
    • Azure + Power BI
    • Microsoft 365 + Power BI
      • Energy
      • Healthcare
      • Manufacturing
      • Media
      • Retail
    • For analysts
    • For IT
      • Overview
      • Embedded analytics
      • Power BI visuals
      • Automation
      • Documentation
      • Community
    • Overview
    • Find consulting services
    • Partner showcase
    • Find a partner
    • Become a partner
    • Instructor-led training
    • Getting started
      • Overview
      • Online workshops
      • Self-guided learning
      • Webinars
      • Documentation
      • Roadmap
      • Overview
      • Issues
      • Give feedback
    • Blog
    • Business intelligence topics
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • Events
    • User groups
    • Community blog
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Galleries
    • Community Connections & How-To Videos
    • COVID-19 Data Stories Gallery
    • Themes Gallery
    • Data Stories Gallery
    • R Script Showcase
    • Webinars and Video Gallery
    • Quick Measures Gallery
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Events
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power BI Community
    • Galleries
    • Quick Measures Gallery
    • Trihybrid Crosses (Genetics)

    Trihybrid Crosses (Genetics)

    01-18-2023 19:06 PM

    Super User Greg_Deckler
    Super User
    334 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    Greg_Deckler
    Super User Greg_Deckler
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Trihybrid Crosses (Genetics)

    ‎01-18-2023 07:06 PM

    This is really kind of a showcase of the issues created by Power BI's "case preemptivity". Power BI's data model isn't really case insensitive per se but it does exhibit case insensitivity in particular circumstances where duplicate strings with different cases are present in the data model. In such cases, the first string "wins" if you will and all other versions of that string with different casing are treated as if they have the exact same casing of the first string. It's weird and it's a real issue in certain circumstances. The hoops you have to jump through to preserve the original casing are absurd. Note that this is a real issue with certain data like SKU numbers and other data where the original casing is super important. 

    Crossed = 
        VAR __Row = MAX('Rows'[Genes])
        VAR __Column = MAX('Columns'[Genes])
        VAR __LenRow = LEN(__Row)
        VAR __LenColumn = LEN(__Column)
        VAR __FirstGeneRow = 
            IF(
                __LenRow = 3,
                LEFT(__Row,1),
                    VAR __Char = FIND(UNICHAR(8203),__Row)
                    VAR __Result = IF(__Char = 2, LEFT(__Row, 2), LEFT(__Row,1))
                RETURN
                    __Result
            )
        VAR __FirstGeneColumn = 
            IF(
                __LenColumn = 3,
                LEFT(__Row,1),
                    VAR __Char = FIND(UNICHAR(8203),__Column)
                    VAR __Result = IF(__Char = 2, LEFT(__Column, 2), LEFT(__Column,1))
                RETURN
                    __Result
            )
        VAR __SecondGeneRow = 
            IF(
                __LenRow = 3,
                MID(__Row,2,1),
                    VAR __Char = FIND(UNICHAR(8203), __Row, LEN(__FirstGeneRow)+1,-1)
                    VAR __Result = IF(__Char <> LEN(__Row) && __Char <> -1, MID(__Row, __Char - 1, 2), MID(__Row, LEN(__FirstGeneRow)+1,1))
                RETURN
                    __Result
            )
        VAR __SecondGeneColumn = 
            IF(
                __LenColumn = 3,
                MID(__Column,2,1),
                    VAR __Char = FIND(UNICHAR(8203), __Column, LEN(__FirstGeneColumn)+1,-1)
                    VAR __Result = IF(__Char <> LEN(__Column) && __Char <> -1, MID(__Column, __Char - 1, 2), MID(__Column, LEN(__FirstGeneColumn)+1,1))
                RETURN
                    __Result
            )
        VAR __FirstGenePair = 
            IF(
                LEN(__FirstGeneRow) > LEN(__FirstGeneColumn),
                __FirstGeneRow & __FirstGeneColumn,
                __FirstGeneColumn & __FirstGeneRow
            )
        VAR __SecondGenePair = 
            IF(
                LEN(__SecondGeneRow) > LEN(__SecondGeneColumn),
                __SecondGeneRow & __SecondGeneColumn,
                __SecondGeneColumn & __SecondGeneRow
            )
        VAR __ThirdGeneRow = 
            IF(
                __LenRow = 3,
                RIGHT(__Row,1),
                    VAR __Char = FIND(UNICHAR(8203), __Row, LEN(__FirstGeneRow) + LEN(__SecondGeneRow) + 1, -1)
                    VAR __Result = IF(__Char <> -1, RIGHT(__Row, 2), RIGHT(__Row, 1))
                RETURN
                    __Result
            )
        VAR __ThirdGeneColumn = 
            IF(
                __LenColumn = 3,
                RIGHT(__Column,1),
                    VAR __Char = FIND(UNICHAR(8203), __Column, LEN(__FirstGeneColumn) + LEN(__SecondGeneColumn) + 1, -1)
                    VAR __Result = IF(__Char <> -1, RIGHT(__Column, 2), RIGHT(__Column, 1))
                RETURN
                    __Result
            )
        VAR __ThirdGenePair = 
            IF(
                LEN(__ThirdGeneRow) > LEN(__ThirdGeneColumn),
                __ThirdGeneRow & __ThirdGeneColumn,
                __ThirdGeneColumn & __ThirdGeneRow
            )
        VAR __FirstGeneProperty = MAXX(FILTER('Gene Pair Properties', [Pair] = __FirstGenePair),[Property])
        VAR __SecondGeneProperty = MAXX(FILTER('Gene Pair Properties', [Pair] = __SecondGenePair),[Property])
        VAR __ThirdGeneProperty = MAXX(FILTER('Gene Pair Properties', [Pair] = __ThirdGenePair),[Property])
        VAR __Result = 
            __FirstGeneProperty & UNICHAR(10) & UNICHAR(13) & 
            __SecondGeneProperty & UNICHAR(10) & UNICHAR(13) & 
            __ThirdGeneProperty & UNICHAR(10) & UNICHAR(13) & 
            __FirstGenePair & __SecondGenePair & __ThirdGenePair
    RETURN
        __Result

    And the video:

    eyJrIjoiMmFhYWM4MTgtMDRmNS00MjQ4LThlNTMtM2NhODVmYjNmODY2IiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9


    @ 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!:
    Mastering Power BI 2nd Edition

    DAX is easy, CALCULATE makes DAX hard...
    Trihybrid Cross.pbix
    Labels:
    • Labels:
    • Other
    Message 1 of 1
    334 Views
    0
    Reply
    • All forum topics
    • Next Topic

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign in
    • Sign up

    Browse

    • Solutions
    • Partners
    • Consulting Services

    Downloads

    • Power BI Desktop
    • Power BI Mobile
    • Power BI Report Server
    • See all downloads

    Learn

    • Guided learning
    • Documentation
    • Support
    • Community
    • Give feedback
    • Webinars
    • Developers
    • Blog
    • Newsletter

    © 2023 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks
    California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices