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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Month bar charts should dynamically changes as per selection done for QTD/YTD/MTD

Hello ,

 

I have a scenario where i need to change my monthly bar chart as per QTD/YTD/MTD.

 

So if i select QTD and only current quarter month bar should appear, If i select MTD then only current MOnth bar and for YTD i should be having complete month bars.

Is there any workaround for this.

 

Thanks!!

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

Sorry to disturb you....

But did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi @Anonymous ,

According to my understand, you want to dynamically display the value based on MTD,QTDand YTD, right?

I did it in two ways.

 

Firstly, create a table for X-axis and for Slicer ,too(values set as MTD,QTD,YTD )

9.16.3.1.png

Method1:

sum value =
VAR _MTD =
    CALCULATE (
        SUM ( 'DateTable'[Cost] ),
        FILTER (
            'DateTable',
            DATEDIFF (
                'DateTable'[Date],
                CALCULATE ( MAX ( 'DateTable'[Date] ), ALL ( DateTable ) ),
                MONTH
            ) = 0
        )
    )
VAR _QTD =
    CALCULATE (
        SUM ( 'DateTable'[Cost] ),
        FILTER (
            'DateTable',
            DATEDIFF (
                'DateTable'[Date],
                CALCULATE ( MAX ( 'DateTable'[Date] ), ALL ( DateTable ) ),
                QUARTER
            ) = 0
        )
    )
VAR _YTD =
    CALCULATE (
        SUM ( 'DateTable'[Cost] ),
        FILTER (
            'DateTable',
            DATEDIFF (
                'DateTable'[Date],
                CALCULATE ( MAX ( 'DateTable'[Date] ), ALL ( DateTable ) ),
                YEAR
            ) = 0
        )
    )
RETURN
SWITCH ( SELECTEDVALUE ( ForX[Cate] ), "MTD", _MTD, "QTD", _QTD, "YTD", _YTD )

9.16.3.1.gif

Method2:

Measure =
VAR _max =
    CALCULATE ( MAX ( 'DateTable'[Date] ), ALL ( DateTable ) )
VAR _MTDFlag =
    IF ( DATEDIFF ( MAX ( 'DateTable'[Date] ), _max, MONTH ) = 0, "MTD", BLANK () )
VAR _QTDFlag =
    IF (
        DATEDIFF ( MAX ( 'DateTable'[Date] ), _max, QUARTER ) = 0,
        "QTD",
        BLANK ()
    )
VAR _YTDFlag =
    IF ( DATEDIFF ( MAX ( 'DateTable'[Date] ), _max, YEAR ) = 0, "YTD", BLANK () )
VAR _finalFlag = _MTDFlag & "-" & _QTDFlag & "-" & _YTDFlag
VAR _sele =
    SELECTEDVALUE ( ForX[Cate] )
RETURN
IF ( CONTAINSSTRING ( _finalFlag, _sele ), 1, 0 )

9.16.3.2.gif

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

amitchandak
Super User
Super User

@Anonymous , I think you need a measure slicer.

https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slicer-parameter-table-pattern

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@Anonymous This shows one way of doing it: https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-EVERYTHING-measures-axis-legend-titles-chart-types/m-p/1027881#M444



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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors