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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
amontemayor
New Member

Calculate the Diffrence of two filtered row in Matrix

amontemayor_1-1668020328812.png

Good Day!

 

Can anyone suggest how to calculate the difference of the Quantity of the two given months? differen

 

1 ACCEPTED SOLUTION

Hi @amontemayor ,

According to your description, here's my solution.

1.Create a month number column, because the month column in text compared by alphabetical instead of real month.

If you have a date column in the table, simply create a calculated column.

MonthNum = MONTH([Date])

If not, a calculated column like this instead:

MonthNum=SWITCH([MonthName],
"January",1,
"February",2,
"March",3,
"April",4
.......

2.Create a measure.

Diff =
VAR _Min =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Item Description] = MAX ( 'Table'[Item Description] )
                && 'Table'[MonthNum] = MINX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
        ),
        'Table'[Quantity]
    )
VAR _Max =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Item Description] = MAX ( 'Table'[Item Description] )
                && 'Table'[MonthNum] = MAXX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
        ),
        'Table'[Quantity]
    )
RETURN
    _Max - _Min

Then get the difference of selected two month. The result is quantity of big month minus quantity of small month. You can either put it in the matrix or a seperate table visual with the Item Description column.

vkalyjmsft_0-1668046311604.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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
amontemayor
New Member

amontemayor_2-1668021178392.png

 

 

 

Hi @amontemayor ,

According to your description, here's my solution.

1.Create a month number column, because the month column in text compared by alphabetical instead of real month.

If you have a date column in the table, simply create a calculated column.

MonthNum = MONTH([Date])

If not, a calculated column like this instead:

MonthNum=SWITCH([MonthName],
"January",1,
"February",2,
"March",3,
"April",4
.......

2.Create a measure.

Diff =
VAR _Min =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Item Description] = MAX ( 'Table'[Item Description] )
                && 'Table'[MonthNum] = MINX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
        ),
        'Table'[Quantity]
    )
VAR _Max =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Item Description] = MAX ( 'Table'[Item Description] )
                && 'Table'[MonthNum] = MAXX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
        ),
        'Table'[Quantity]
    )
RETURN
    _Max - _Min

Then get the difference of selected two month. The result is quantity of big month minus quantity of small month. You can either put it in the matrix or a seperate table visual with the Item Description column.

vkalyjmsft_0-1668046311604.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors