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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
polman4
Helper I
Helper I

Compare Column in a matrix

Hello,

 

I have a matrix with the following data

Rows

Author

 

Column

Week Start Date = (nw_content[nw_c_publishdate]-WEEKDAY(nw_content[nw_c_publishdate],3)

 

Values

Pageviews.

 

Below is the usual i create:

polman4_1-1656416327850.png

 

What i want to do is after the compare a column data with the previous "column". For example after the column called 6/6/2022 to compare 186.702 to 176.011

I have figured out how to compare two different column or the in same column by previous month etc. But here is a custom column and don't know how to define "previous" column.

 

p.s. this is how i used to do it on excel.

polman4_2-1656416784063.png

 

Any help appreciated it!

thank you

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

Hi, @polman4 ,

Create a measure ,

diff = var _max=CALCULATE(MAX('Table'[Column]),FILTER(ALL('Table'),[author]=MAX([author])&& [Column]<MAX([Column])))
var _pir= CALCULATE(SUM([value]),FILTER(ALL('Table'),[author]=MAX([author])&&[Column]=_max))
var _result= DIVIDE(SUM([value]),_pir)-1
return IF(_result=-1,BLANK(),_result)

Or create a column.

differ = var _max=CALCULATE(MAX('Table'[Column]),FILTER(ALL('Table'),[author]=EARLIER([author])&& [Column]<EARLIER([Column])))
var _pir= CALCULATE(SUM([value]),FILTER(ALL('Table'),[author]=EARLIER([author])&&[Column]=_max))
var _result= DIVIDE([value],_pir)-1
return IF(_result=-1,BLANK(),_result)

The final show:

vyalanwumsft_0-1656659491472.png


Best Regards,
Community Support Team _ Yalan Wu
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

7 REPLIES 7
v-yalanwu-msft
Community Support
Community Support

Hi, @polman4 ;

diff = var _max=CALCULATE(MAX('Table'[Column]),FILTER(ALL('Table'),[author]=MAX([author])&& [Column]<MAX([Column])))
var _pir= CALCULATE(SUM([value]),FILTER(ALL('Table'),[author]=MAX([author])&&[Column]=_max))
var _total=CALCULATE(SUM([value]),FILTER(ALL('Table'),[Column]=_max))
var _result= DIVIDE(SUM([value]),_pir)-1
return  IF(_result=-1,BLANK(),IF(ISINSCOPE('Table'[author]),_result,DIVIDE(SUM([value]),_total)-1))

The final show:

vyalanwumsft_0-1658801962977.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yalanwu-msft
Community Support
Community Support

Hi, @polman4 ;

Try it.

% PPA =
VAR _max =
    CALCULATE (
        MAX ( 'nw_content'[Week_Start_Date] ),
        FILTER (
            ALL ( 'nw_content' ),
            [Author_Clm] = MAX ( [Author_Clm] )
                && [Week_Start_Date] < MAX ( [Week_Start_Date] )
        )
    )
VAR _pir =
    SUMX (
        FILTER (
            ALL ( 'nw_content' ),
            [Author_Clm] = MAX ( [Author_Clm] )
                && [Week_Start_Date] = _max
        ),
        nw_content[PPA]
    )
VAR _result =
    DIVIDE ( SUMX ( nw_content, nw_content[PPA] ), _pir ) - 1
RETURN
    IF ( _result = -1, "no data", _result )


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

polman4
Helper I
Helper I

@v-yalanwu-msft Thank you a lot of the awesome solutions. Really helped me a lot learning new things. Got a last question if you can help.
I have some columns that are measure so i made a small change to the measure: (used sumx)

 

% PPA = 
VAR _max =
    CALCULATE (
        MAX ( 'nw_content'[Week_Start_Date] ),
        FILTER (
            ALL ( 'nw_content' ),
            [Author_Clm] = MAX ( [Author_Clm] )
                && [Week_Start_Date] < MAX ( [Week_Start_Date] )
        )
    )
VAR _pir =
    CALCULATE (
        SUMX(nw_content, nw_content[PPA]),
        FILTER ( ALL ( 'nw_content' ), [Author_Clm] = MAX ( [Author_Clm] ) && [Week_Start_Date] = _max )
        )
VAR _result =
    DIVIDE ( SUMX(nw_content, nw_content[PPA]), _pir ) - 1
RETURN
    IF ( _result = -1, "no data", _result )

 

But the result doesn't seem to be correct.
Here is the PPA measure:

 

PPA = (sum('nw_content'[Pageviews])/ DISTINCTCOUNT('nw_content'[nw_c_pageuid]))

 

 

Maybe i shouldn't use sumx?

 

Thank you!

v-yalanwu-msft
Community Support
Community Support

Hi, @polman4 ,

You could add another measure,

Measure = IF(ISINSCOPE('Table'[author]),[diff],SUMX( SUMMARIZE('Table',[author], [Column],"1",[diff]),[1]))

The final show:

vyalanwumsft_0-1657004362485.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yalanwu-msft 

I did a review today on some data and I think the measure % is not correct. If i'm not mistaken, what you is to summarize the percentages above. But this isn't correct mathematically.

Also if you do the calculation (211.51 / 194.66) -1  = 8,76. Not 39,07.

Thank you!

v-yalanwu-msft
Community Support
Community Support

Hi, @polman4 ,

Create a measure ,

diff = var _max=CALCULATE(MAX('Table'[Column]),FILTER(ALL('Table'),[author]=MAX([author])&& [Column]<MAX([Column])))
var _pir= CALCULATE(SUM([value]),FILTER(ALL('Table'),[author]=MAX([author])&&[Column]=_max))
var _result= DIVIDE(SUM([value]),_pir)-1
return IF(_result=-1,BLANK(),_result)

Or create a column.

differ = var _max=CALCULATE(MAX('Table'[Column]),FILTER(ALL('Table'),[author]=EARLIER([author])&& [Column]<EARLIER([Column])))
var _pir= CALCULATE(SUM([value]),FILTER(ALL('Table'),[author]=EARLIER([author])&&[Column]=_max))
var _result= DIVIDE([value],_pir)-1
return IF(_result=-1,BLANK(),_result)

The final show:

vyalanwumsft_0-1656659491472.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yalanwu-msft 

 

Thank you for the detailed reply. Took almost a week to understand but was really helpfull and learned a lot.

Quick question. I guess it can't work for totals?

 

polman4_0-1656943883957.png

Thank you!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors