Forum Discussion
gmasta1129
Resolver I
1 year agoCompare 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...
- Anonymous1 year ago
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.
If this helps solve your issue, kindly consider Accept it as a solution so other community members can find it useful too.
Reagrds,
Harshitha.
vicky_
Super User
1 year agoTry 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])))