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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
jkoclejda
Helper I
Helper I

Comparing the same days of the current month year to year

Hi!

 

I have a simple bar chart that shows monthly revenue broken down by years

jkoclejda_0-1673970306915.png

It's January now, and there's no point in comparing half a month to whole month in previous years. 

 

I am wondering how to write a calculation formula that would show the sum for the period of days that have passed in the current month and the total for the remaining months?

 

So today (January 17, 2023) , for past years, the chart will show a comparison only up to and including January 16. If today was February 3rd, the chart will show full January (and the remaining months after February), but for February only up to the 3rd day.

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Hi @jkoclejda 

Here's a measure that uses a separate date table (called Baseline Date in my model) that has a month number column.  You would replace the 'Baseline Activity Count' measure with your revenue (or whatever) measure.

Monthly Comparison = 
VAR _Today = TODAY()
VAR _Month = SELECTEDVALUE('Baseline Date'[Baseline Month Num])
VAR _CurrentMonth = MONTH(_Today)
VAR _Result = 
IF(_CurrentMonth = _Month,
    CALCULATE(
        [Baseline Activity Count],
        //get dates to today
        FILTER(VALUES('Baseline Date'[Baseline Date]), DAY('Baseline Date'[Baseline Date]) <= DAY(_Today))
    ),
    //use the measure as is, in effect getting all dates for the month
    [Baseline Activity Count]
)
RETURN
    _Result

 

PaulOlding_0-1674050104633.png

 

View solution in original post

5 REPLIES 5
PaulOlding
Solution Sage
Solution Sage

Hi @jkoclejda 

Here's a measure that uses a separate date table (called Baseline Date in my model) that has a month number column.  You would replace the 'Baseline Activity Count' measure with your revenue (or whatever) measure.

Monthly Comparison = 
VAR _Today = TODAY()
VAR _Month = SELECTEDVALUE('Baseline Date'[Baseline Month Num])
VAR _CurrentMonth = MONTH(_Today)
VAR _Result = 
IF(_CurrentMonth = _Month,
    CALCULATE(
        [Baseline Activity Count],
        //get dates to today
        FILTER(VALUES('Baseline Date'[Baseline Date]), DAY('Baseline Date'[Baseline Date]) <= DAY(_Today))
    ),
    //use the measure as is, in effect getting all dates for the month
    [Baseline Activity Count]
)
RETURN
    _Result

 

PaulOlding_0-1674050104633.png

 

Anonymous
Not applicable

Hi  @jkoclejda ,

I created some data:

vyangliumsft_0-1674025166914.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _todat=TODAY()
return
IF(
    MAX('Table'[Month]) = FORMAT(_todat,"mmm"),1,0)
Measure =
var _today=
TODAY()
return
SUMX(
    FILTER(ALLSELECTED('Table'),    'Table'[Year]=YEAR(MAX('Table'[Date]))&&MONTH('Table'[Date])=MONTH(_today)&&DAY('Table'[Date])<=DAY(_today)),[Value])

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1674025166916.png

3. Result:

vyangliumsft_2-1674025166920.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thank you for your answer but that's not quite what I'm looking for. I would like the chart to show full data for months other than the current one and comparison to the current day only for the current month. 

On January 18 2023, the chart will show a comparison of January 1-17 for individual years - 2020, 2021, 2022, 2023. The remaining months (February to December) for the years 2020-2022 will be presented normally.

 

On March 7, 2023, the chart will show a comparison of March 1-6 for the years 2020-2023. Full January and February data for 2020-2023 and full April-December data for 2020-2022.

Greg_Deckler
Community Champion
Community Champion

@jkoclejda You can use DAX's EDATE function for things like that.



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...

@Greg_Deckler Can you give me an example based on my case? Should I use it with IF to make it works only with current month

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.