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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Find Difference Between Rows in Table based on criteria

I am trying to calculate the total punches percent change compared to the punches for 3/15/20, for each date for each subvertical. I've included an example of the data below, the last column is what I am trying to calculate. So for the first row, I need the formula to be pulling 981,000/987,000 and anytime the date is 3/15/20 it should be showing 100%. Can anyone help me?

 

Vertical Data.JPG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below:

Difference from 3/15 = 
VAR _punchonMar15 =
    CALCULATE (
        SUM ( 'Punch info'[Total Punches] ),
        'Punch info'[Date] = DATE ( 2020, 3, 15 )
    )
RETURN
    IF (
        MAX ( 'Punch info'[Date] ) = DATE ( 2020, 3, 15 ),
        1,
        1
            - DIVIDE ( _punchonMar15 - SUM ( 'Punch info'[Total Punches] ), _punchonMar15 )
    )

difference with Mar 15.JPG

Best Regards

Rena

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below:

Difference from 3/15 = 
VAR _punchonMar15 =
    CALCULATE (
        SUM ( 'Punch info'[Total Punches] ),
        'Punch info'[Date] = DATE ( 2020, 3, 15 )
    )
RETURN
    IF (
        MAX ( 'Punch info'[Date] ) = DATE ( 2020, 3, 15 ),
        1,
        1
            - DIVIDE ( _punchonMar15 - SUM ( 'Punch info'[Total Punches] ), _punchonMar15 )
    )

difference with Mar 15.JPG

Best Regards

Rena

Anonymous
Not applicable

Not sure if I'm supposed to start a new post or not but is there a way to add a 'total' line to the chart now that will just sum whatever lines I'm showing? 

Anonymous
Not applicable

Hi @Anonymous ,

You can follow the below steps to get the total line:

1. Select the related visual, navigate to "Format" pane and turn on the option "Totals"  

2. Create another measure with below formula in order to get the correct total value, then put this new measure on the visual to replace the orignal measure "Difference from 3/15"

Measure 2 = SUMX(VALUES('Punch info'[Sub Vertical]),[Difference from 3/15])

difference with Mar 15_2.JPG

Best Regards

Rena

 

 

Anonymous
Not applicable

Sorry, I think I should have been more specific... I have this in a line graph, with percent on the x axis and subvertical on the y. I want to add a line for a total of the subverticals - so summing up all the punches and then calculating the difference from 3/15/20...

Anonymous
Not applicable

Thank you!! This worked perfectly and the visual really helped!!

mahoneypat
Microsoft Employee
Microsoft Employee

Not sure if you are looking for a column or measure expression, so you can try this expression in a measure, replacing Table with your actual table name.

 

Difference from March15 =
VAR __sumthisdate =
    SUM ( Table[Total Punches] )
VAR __sumMarch15 =
    CALCULATE (
        SUM ( Table[Total Punches] ),
        ALL ( Table[Date] ),
        Table[Date] = DATE ( 2020, 3, 15 )
    )
RETURN
    DIVIDE ( __sumthisdate - __sumMarch15, __sumMarch15 )

 

For the measure version, remove the SUM in the first variable (just Table[Total Punches]) and change the ALL in the 2nd variable to ALLEXCEPT(Table, Table[Sub Vertical])

 

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.