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
    • Office 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
    • DB

    DB

    05-09-2020 21:42 PM

    Super User Greg_Deckler
    Super User
    415 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
    • Email to a Friend
    • Report Inappropriate Content

    DB

    ‎05-09-2020 09:42 PM

    In my recent quest to create or catalog as many DAX equivalents for Excel functions, because DB involves recursion, there is no "clean" DAX solution, it's ugly and you have to use reasonable maximum. 😞

    DB = 
        VAR __Cost = [Cost]
        VAR __Salvage = [Salvage]
        VAR __Life = [Life]
        VAR __Period = MAX('Table'[Year])
        VAR __Month = IF(ISBLANK([Month]),12,[Month])
        VAR __Rate = ROUND(1 - POWER( __Salvage / __Cost,(1/__Life)),3)
        VAR __Table1 = { (1, __Cost * __Rate * __Month/12) }
        VAR __Table2 = { (2, (__Cost - SUMX(__Table1,[Value2])) * __Rate) }
        VAR __Table3 = { (3, (__Cost - SUMX(UNION(__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table4 = { (4, (__Cost - SUMX(UNION(__Table3,__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table5 = { (5, (__Cost - SUMX(UNION(__Table4,__Table3,__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table6 = { (6, (__Cost - SUMX(UNION(__Table5,__Table4,__Table3,__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table7 = { (7, (__Cost - SUMX(UNION(__Table6,__Table5,__Table4,__Table3,__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table8 = { (8, (__Cost - SUMX(UNION(__Table7,__Table6,__Table5,__Table4,__Table3,__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table9 = { (9, (__Cost - SUMX(UNION(__Table8,__Table7,__Table6,__Table5,__Table4,__Table3,__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table10 = { (10, (__Cost - SUMX(UNION(__Table9,__Table8,__Table7,__Table6,__Table5,__Table4,__Table3,__Table2,__Table1),[Value2])) * __Rate) }
        VAR __Table = UNION(__Table10, __Table9,__Table8,__Table7,__Table6,__Table5,__Table4,__Table3,__Table2,__Table1)
    RETURN
        SWITCH(
            TRUE(),
            __Period <> __Life + 1,MAXX(FILTER(__Table,[Value1] = __Period),[Value2]),
            __Period = __Life + 1,( (__Cost - SUMX(FILTER(__Table, [Value1] < __Period),[Value2]) ) * __Rate * (12-__Month)) / 12
        )

    eyJrIjoiNWMwNWUyNmYtYWI3Mi00ZGZmLTg5ZTYtZDY1N2I3ZDNmYmRlIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9


    @ me in replies or I'll lose your thread!!!
    Become an expert!: Enterprise DNA
    External Tools: MSHGQM
    YouTube Channel!: Microsoft Hates Greg
    Latest book!:
    Learn Power BI 2nd Edition
    Preview file
    50 KB
    DB.pbix
    Labels:
    • Labels:
    • Financial
    Message 1 of 1
    415 Views
    1
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • 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

    © 2022 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks