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
KingJoel
Regular Visitor

Calculate difference in New measures

Calculate difference in New measure as +/- change and also % change from prior day.  Pulling my hair our crating this.

 

If day is True then subtract prior day that is True show the differance.

also calculate in a  second column as a % of change.

 

KingJoel_0-1704305220485.png

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @KingJoel 

You can refer to the following sample

vxinruzhumsft_0-1704347563565.png

Then line_total and the workday are the measures

line_total = SUM('Table'[Sum]) 
Work Day = IF(MAX('Table'[False/true])=1,TRUE(),FALSE())

 Original data 

vxinruzhumsft_1-1704347666779.png

You can create the following measures

Diff =
IF (
    [Work Day] = TRUE (),
    VAR a =
        MAXX (
            FILTER (
                ALLSELECTED ( 'Table' ),
                [load_date] < MAX ( 'Table'[load_date] )
                    && [Work Day] = TRUE ()
            ),
            [load_date]
        )
    RETURN
        [line_total]
            - CALCULATE ( [line_total], 'Table'[load_date] = a )
)
%diff = [Diff]/[line_total]

Output

vxinruzhumsft_2-1704347815055.png

Best Regards!

Yolo Zhu

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

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @KingJoel 

You can refer to the following sample

vxinruzhumsft_0-1704347563565.png

Then line_total and the workday are the measures

line_total = SUM('Table'[Sum]) 
Work Day = IF(MAX('Table'[False/true])=1,TRUE(),FALSE())

 Original data 

vxinruzhumsft_1-1704347666779.png

You can create the following measures

Diff =
IF (
    [Work Day] = TRUE (),
    VAR a =
        MAXX (
            FILTER (
                ALLSELECTED ( 'Table' ),
                [load_date] < MAX ( 'Table'[load_date] )
                    && [Work Day] = TRUE ()
            ),
            [load_date]
        )
    RETURN
        [line_total]
            - CALCULATE ( [line_total], 'Table'[load_date] = a )
)
%diff = [Diff]/[line_total]

Output

vxinruzhumsft_2-1704347815055.png

Best Regards!

Yolo Zhu

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

Kaviraj11
Super User
Super User

Here is an example:
Changes =
var _selecteddate= FIRSTDATE('Calendar'[Date])
var _selecteddate1= FIRSTDATE('Calendar'[Date])-1
var Total =CALCULATE([YourMeasure),TREATAS({_selecteddate},'Calendar'[Date]))
var PreviousDayTotal=CALCULATE([YourMeasure),TREATAS({_selecteddate1},'Calendar'[Date]))
RETURN
IF([WorkDay]="True",BLANK(),Total -PreviousDayTotal)
 
Changes % =
var _selecteddate= FIRSTDATE('Calendar'[Date])
var _selecteddate1= FIRSTDATE('Calendar'[Date])-1
var Total =CALCULATE([YourMeasure),TREATAS({_selecteddate},'Calendar'[Date]))
var PreviousDayTotal=CALCULATE([YourMeasure),TREATAS({_selecteddate1},'Calendar'[Date]))
RETURN
IF([WorkDay]="True",BLANK(),((Total -PreviousDayTotal)/Total)*100)



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.