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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
gmasta1129
Helper III
Helper III

Compare Month to Month Data

Hello, I have a table that contains the following columns:

 

1. Run Date

2. Facility Code

3. NAV Date

4. Total NAV Value

 

I would like to create a measure to show the difference in "Total NAV Value" by NAV Date (month end date to month end date) and Facility Code. 

 

For example, Facility Code "11111", the difference between the "Total NAV Value" from "NAV Date" 5/30/2025 to 4/30/2025 is $5,000,000 (1,000,000 - 6,000,000) and the difference between "NAV Date" 4/30/2025 to 3/31/2025 is $2,000,000 (6,000,000-4,000,000).  

 

 

 

Run DateFacility CodeNAV DateTotal NAV Value
6/1/2025111115/31/2025       1,000,000.00
6/1/2025222225/31/2025       5,000,000.00
5/25/2025111114/30/2025       6,000,000.00
5/25/2025222224/30/2025     20,000,000.00
4/10/2025111113/31/2025       4,000,000.00
4/10/2025222223/31/2025     15,000,000.00
1 ACCEPTED SOLUTION
v-hjannapu
Community Support
Community Support

Hi @gmasta1129  ,

Thank you  for reaching out to the Microsoft fabric community forum.
Thank you @vicky_ , for your response regarding the issue.

You can create the following DAX measure to calculate the NAV difference from the previous month for each Facility Code:

NAV Difference = 
VAR CurrentNAVDate = MAX('NAV_Data'[NAV Date])
VAR CurrentFacility = MAX('NAV_Data'[Facility Code])
VAR CurrentNAV =
    CALCULATE(
        SUM('NAV_Data'[Total NAV Value]),
        'NAV_Data'[Facility Code] = CurrentFacility,
        'NAV_Data'[NAV Date] = CurrentNAVDate
    )
VAR PrevNAVDate =
    CALCULATE(
        MAX('NAV_Data'[NAV Date]),
        FILTER(
            ALL('NAV_Data'),
            'NAV_Data'[Facility Code] = CurrentFacility &&
            'NAV_Data'[NAV Date] < CurrentNAVDate
        )
    )
VAR PrevNAV =
    CALCULATE(
        SUM('NAV_Data'[Total NAV Value]),
        'NAV_Data'[Facility Code] = CurrentFacility,
        'NAV_Data'[NAV Date] = PrevNAVDate
    )
RETURN
    IF(
        ISBLANK(PrevNAV),
        BLANK(),
        CurrentNAV - PrevNAV
    )

I tested it with my sample data, and it worked fine. Please find the attached screenshot and pbix for your reference.

vhjannapu_0-1750142207937.png
If this helps solve your issue, kindly consider Accept it as a solution so other community members can find it useful too.
Reagrds,
Harshitha.

View solution in original post

3 REPLIES 3
v-hjannapu
Community Support
Community Support

Hi @gmasta1129  ,

Thank you  for reaching out to the Microsoft fabric community forum.
Thank you @vicky_ , for your response regarding the issue.

You can create the following DAX measure to calculate the NAV difference from the previous month for each Facility Code:

NAV Difference = 
VAR CurrentNAVDate = MAX('NAV_Data'[NAV Date])
VAR CurrentFacility = MAX('NAV_Data'[Facility Code])
VAR CurrentNAV =
    CALCULATE(
        SUM('NAV_Data'[Total NAV Value]),
        'NAV_Data'[Facility Code] = CurrentFacility,
        'NAV_Data'[NAV Date] = CurrentNAVDate
    )
VAR PrevNAVDate =
    CALCULATE(
        MAX('NAV_Data'[NAV Date]),
        FILTER(
            ALL('NAV_Data'),
            'NAV_Data'[Facility Code] = CurrentFacility &&
            'NAV_Data'[NAV Date] < CurrentNAVDate
        )
    )
VAR PrevNAV =
    CALCULATE(
        SUM('NAV_Data'[Total NAV Value]),
        'NAV_Data'[Facility Code] = CurrentFacility,
        'NAV_Data'[NAV Date] = PrevNAVDate
    )
RETURN
    IF(
        ISBLANK(PrevNAV),
        BLANK(),
        CurrentNAV - PrevNAV
    )

I tested it with my sample data, and it worked fine. Please find the attached screenshot and pbix for your reference.

vhjannapu_0-1750142207937.png
If this helps solve your issue, kindly consider Accept it as a solution so other community members can find it useful too.
Reagrds,
Harshitha.

Hello @v-hjannapu ,

 

The formula worked! Thank you so much for your help! 😀😀

vicky_
Super User
Super User

Try the below:

Difference = SUM('Table'[Total NAV Value]) - CALCULATE(SUM('Table'[Total NAV Value]), OFFSET(-1, DISTINCT(ALLSELECTED('Table')), ORDERBY('Table'[NAV Date], DESC), PARTITIONBY('Table'[Facility Code])))

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors