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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
RafaelAguirre02
Frequent Visitor

Comparing 30 day months vs 31 day months.

Hello

 

I'm trying to compare current Vs previous month balance daily in a matrix (Columns - Days ofmonth, Rows - Stages, Values - Balance).

 

When the current month has less days than the previous month the Columns display only the days for the current month, causing the previous month's data to disappear.

 

For example, if i'm comparing November vs October in will only display values until day 30 although October (Prev. Month) has 31 days. i would like to compare day 30 of november with day 30 and day 31 of october.

 

How can i fix this problem?

1 ACCEPTED SOLUTION

True, but in this case because of the type of business, the cadence of the weekdays does not affect the value of the daily analysis.

As for the solution I worked with your idea and helped me achieve my goal! For the current month calculation a used the following measure:

Current_Month =
VAR CALC = CALCULATE(SUM(Data[Balance]),filter('Calendar','Calendar'[Day] = MAX(Days[Days])))
Return
IF(
    ISBLANK(CALC),
    CALCULATE(SUM(Data[Balance]),
    LASTDATE(Data[Date])
    ),
    CALC
)

For the comparative month measure i only calculated this past measure but filtered by a inactive secondary calendar table:

Comparative_Month = CALCULATE([Current_Month],ALL(Calendar),
    USERELATIONSHIP(Calendar[Date],Calendar_Inactive[Baseline Date]))

From there i only made the measure to calculate the difference.

View solution in original post

3 REPLIES 3
gmsamborn
Super User
Super User

Hi @RafaelAguirre02 

 

Would it make sense to calculate an average daily sales by dividing sales by the number of days in the month?

Then you can repeat the calculation for the previous month and then make comparisons.

I've used this in the past in a similar scenario and the users actually preferred it.

 

Let me know if this would be an option.

lbendlin
Super User
Super User

You are omitting the fact that the weekday cadence will be different between these months, so comparing day vs day is pretty meaningless anyway.

 

You would need a disconnected table with a list from 1 to 31 and a measure to achieve your desired result.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

True, but in this case because of the type of business, the cadence of the weekdays does not affect the value of the daily analysis.

As for the solution I worked with your idea and helped me achieve my goal! For the current month calculation a used the following measure:

Current_Month =
VAR CALC = CALCULATE(SUM(Data[Balance]),filter('Calendar','Calendar'[Day] = MAX(Days[Days])))
Return
IF(
    ISBLANK(CALC),
    CALCULATE(SUM(Data[Balance]),
    LASTDATE(Data[Date])
    ),
    CALC
)

For the comparative month measure i only calculated this past measure but filtered by a inactive secondary calendar table:

Comparative_Month = CALCULATE([Current_Month],ALL(Calendar),
    USERELATIONSHIP(Calendar[Date],Calendar_Inactive[Baseline Date]))

From there i only made the measure to calculate the difference.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.