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
    • Dynamics 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
    • Re: Dynamic EVERYTHING (measures, axis, legend, ti...

    Re: Dynamic EVERYTHING (measures, axis, legend, titles, chart types)

    08-11-2020 01:02 AM - last edited 08-11-2020 01:03 AM

    rgarancs
    Frequent Visitor
    7294 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    rgarancs
    rgarancs
    Frequent Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Dynamic EVERYTHING (measures, axis, legend, titles, chart types)

    ‎04-15-2020 09:09 AM

    This solution shows layered dynamic DAX measures, i.e. how one chart can show different values, in different time frames, different scale. Report also shows how a slicer can be used to dynamically change axis and legend. Report has dynamic title and switch for chart types. Database layout is quite simple (and can be used for other cases) but uses a bit of trickery to create such dynamic solution using slicers to change axis/legend. 

     

    This is how some steps are made:

     

    Dynamic_value = SWITCH(SELECTEDVALUE(Value_filter[Value field],"Volume"),
    "Volume",SUM('Master'[Volume]),
    "Value",SUM('Master'[Value]),
    "Price",DIVIDE(SUM('Master'[Value]),SUM('Master'[Volume])),
    "Distribution",DIVIDE(SUM('Master'[Distribution relevant rate]),SUM('Master'[Volume])))

     

    Step2:

     

    Dynamic_value_step_2 = SWITCH(SELECTEDVALUE(tbl_time[Time],"Free range"),
    "Month-to-date",TOTALMTD([Dynamic_value],Master[Date].[Date]),
    "Year-to-date",TOTALYTD([Dynamic_value],Master[Date].[Date]),
    "Full year",CALCULATE([Dynamic_value],ALL(Master[Date].[Date])),
    "Free range",[Dynamic_value])

     

     Last step:

     

    Dynamic_value_step_4 = SWITCH(SELECTEDVALUE(tbl_vs[versus],"absolute numbers"),
    "absolute numbers",[Dynamic_value_step_3],
    "versus LY",[Dynamic_value_step_3]-CALCULATE([Dynamic_value_step_3],SAMEPERIODLASTYEAR(Master[Date].[Date])),
    "versus LM",[Dynamic_value_step_3]-CALCULATE([Dynamic_value_step_3],DATEADD(Master[Date].[Date],-1,MONTH)),
    "versus LQ",[Dynamic_value_step_3]-CALCULATE([Dynamic_value_step_3],DATEADD(Master[Date].[Date],-1,QUARTER))
    )

     

     

    Dynamic title:

     

    Title 1 = var val = SELECTEDVALUE(Value_filter[Value field])
    var ax = SELECTEDVALUE('Database axis'[Attribute])
    var leg = SELECTEDVALUE('Database legend'[Attribute])
    var yrs = SELECTEDVALUE(Master[Date].[Year])
    var mnh = SELECTEDVALUE(Master[Date].[Month])
    var qrt = SELECTEDVALUE(Master[Date].[Quarter])
    var ver = SELECTEDVALUE(tbl_vs[versus])
    var tme = SELECTEDVALUE(tbl_time[Time])
    var scl = SELECTEDVALUE(tbl_scale[Scale])
    return
    TRIM(val& " for "& ax & " split by "& leg&": "&yrs&" "&qrt&" "&mnh&" "&SWITCH(tme,"Month-to-date","MTD","Year-to-date","YTD","Free range",BLANK())&" "&IF(ver="absolute numbers",BLANK(),ver)&" "&IF(scl="Thousands","in "&LOWER(scl),BLANK()))

     

     

     

     

    eyJrIjoiZGQxZjRmNDctNWMyMi00MjUwLTg5MDctNmY1YmQ4YWVlNjk1IiwidCI6ImEwNGM1MWNiLTUyOTYtNDE3ZC1iNjEyLWRjMzNhMDI4ZDdhMCIsImMiOjh9

    Preview file
    158 KB
    Dynamic DAX.pbix
    Labels:
    • Labels:
    • Filters
    • Other
    • Time Intelligence
    Message 1 of 6
    8,177 Views
    5
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    Anonymous
    Not applicable
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎03-25-2022 01:04 AM

    Hi @rgarancs ,

     

    Your visual is indeed very dynamic. I am looking for something similar. I downlaoded your .pbix version but I open it, it ask me to install R else few features aren't working. I do not work on R/Python. Does your workbook all functionalities works only with R? When I am using it without R, I cannot see any logics you have designed. Like when I click on Database Legend table or any column, it is not showing me DAX behind it.

     

    Regards

    Preview file
    63 KB
    Message 6 of 6
    3,050 Views
    0
    Reply
    perezco
    perezco Advocate III
    Advocate III
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-06-2020 08:01 AM

    HI @rgarancs ,

     

    Nice work  and extremelly dynamic!!  😍

     Could be possible that you can provide general details of what need to be considered at the moment to do tables for the model that you made? 

     

    Regards,
    Cristina 

    Message 4 of 6
    7,413 Views
    0
    Reply
    rgarancs
    rgarancs
    Frequent Visitor
    In response to perezco
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-11-2020 01:02 AM

    Hi, @perezco ,

     

    Any normal databse with KPIs in seperate columns should work with this setup as long as all fact data is in the same table (have not yet tested multi-fact table solution myself).

    If you need both dynamic axis and dymanic legend with cross filtering function, that will make it more difficult in terms of database setup, but in general you need to have a regular fact table to which you add index column and then unpivot all values, seperately there is a mirror table that removes values but keeps only names (e.g. KPI names) which then are liked with both directions. 

     

    You can see the end result in the .pbix file, it has two sets of same data to include cross filtering and legends, thus this databse can be simplified if less features are required. 

     

    Hope this helps. 

    Message 5 of 6
    7,294 Views
    1
    Reply
    Greg_Deckler
    Super User Greg_Deckler
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-15-2020 11:12 AM
    Seems like this would require a very specific dataset layout but can't tell because no PBIX.

    @ 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...
    Message 2 of 6
    8,153 Views
    0
    Reply
    rgarancs
    rgarancs
    Frequent Visitor
    In response to Greg_Deckler
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-16-2020 12:47 AM

    You're right, it does require atypical database layout, but it is quite easy to create and can be replicated. Also, I added the pbix file that can be reviewed and used for similar solutions. 

    Message 3 of 6
    8,128 Views
    0
    Reply

    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