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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
drijo
New Member

How to fix Date X Axis?

Hello! To give context I am trying to count the number of transactions done in established periods such as 

(Actual month or Past month). For this, I used calculated measures: 

Actual Month =

VAR EARLIESTYEAR = YEAR(MAX(Transaccional[Date]))

VAR EARLIESTMONTH = MONTH(MAX(Transaccional[Date]))

VAR EARLIESTDAY = DAY(MAX(Transaccional[Date]))

RETURN

    CALCULATE(count(Transaccional[TransactionId]),

        FILTER(Transaccional,  

        YEAR([Date])=EARLIESTYEAR &&

        MONTH([Date])=EARLIESTMONTH &&

        DAY([Date])<=EARLIESTDAY

))

 

Interanual Month = CALCULATE(

count(Transaccional[TransactionId]),

FILTER(Transaccional,

YEAR([Date])=YEAR(MAX([Date]))-1 &&

MONTH([Date])= MONTH(MAX([Date])) &&

if(MAX([Date])<>EOMONTH(MAX([Date]),0),Day(Transaccional[Date])<=DAY(MAX([Date])) ,DAY([Date])>=DAY(MAX([Date])) || DAY([Date])<=DAY(MAX([Date])))

 

))

 

Previous month = CALCULATE(

count(Transaccional[TransactionId]),

FILTER(Transaccional,

YEAR([Date])=YEAR(MAX([Date])) &&

MONTH([Date])= MONTH(MAX([Date]))-1 &&

if(MAX([Date])<>EOMONTH(MAX([Date]),0),Day(Transaccional[Date])<=DAY(MAX([Date])) ,DAY([Date])>=DAY(MAX([Date])) || DAY([Date])<=DAY(MAX([Date])))

))

 

The purpose of this formula is to make the data visualization dynamic since I want the user to filter the data, and depending on those changes I want the graph to change. I am certain that the formulas work just fine. Still, when I have to graph the measures, the X axis corresponding to the date (specifically DAY), the numbers are wrongly distributed along the X axis. For example: 

 

unnamed.pngThe latest date on this data is (6/19/2024) but the measure shows values up to day 30, which means that the data is not well aligned. I have tried and thought this a lot but don't know what the solution would be. 

2 REPLIES 2
lbendlin
Super User
Super User

Simplify your measure to use EDATE(-1) for the previous month and EDATE(-12) for the same month last year.  Note that the majority of "Previous Month" combinations will have different numbers of days, making the comparison less useful. And even with the same month last year the weekdays will differ which may again skew the comparison.

Thanks for the rec! I was trying to graph it that way since it was a request from my supervisor because they usually like to see the number of transactions per day for those months (I only could achieve that by using calculated columns, but they aren't a dynamic way to observe the data since it cannot be filtered), but it seems that it cannot be graphed?  

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.