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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Aggregate Matrix Based on Filters and Measures

I am trying to create a calculated matrix in Power BI.

 

Here is my source data:

andrewseaman_0-1594014171919.png

 

Here is what I am able to get to currently.  Note Balance_1 is based on filtering to Version One.  Balance_2 is based on filtering to Version Two.  The users need to be able to filter between versions.  I then do a measure calculation in the explanation column.

 

andrewseaman_1-1594014262545.png

 

How can I then summarize this view similar to the below?

andrewseaman_2-1594014296189.png

 

 

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please check:

 

1. Enter data to make an Explannation table.

expla.PNG

 

2. Sort by [Explanation] column by [Order] column.

sortby.jpg

 

3. Create measures like so:

Balance_1_Sum = 
VAR t =
    SUMMARIZE (
        'Table',
        'Table'[Customer],
        'Table'[ID],
        "Balance1", [Balance_1],
        "Balance2", [Balance_2],
        "Explanation_", [Explanation]
    )
RETURN
    SUMX (
        FILTER ( t, [Explanation_] = SELECTEDVALUE ( Explanation[Explanation] ) ),
        [Balance1]
    )
Delta_Sum = 
VAR t =
    SUMMARIZE (
        'Table',
        'Table'[Customer],
        'Table'[ID],
        "Balance1", [Balance_1],
        "Balance2", [Balance_2],
        "Explanation_", [Explanation],
        "Delta_", ABS ( [Balance_2] - [Balance_1] )
    )
RETURN
    SUMX (
        FILTER ( t, [Explanation_] = SELECTEDVALUE ( Explanation[Explanation] ) ),
        [Delta_]
    )

 

4. Create a Table visual like so:

explain.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please check:

 

1. Enter data to make an Explannation table.

expla.PNG

 

2. Sort by [Explanation] column by [Order] column.

sortby.jpg

 

3. Create measures like so:

Balance_1_Sum = 
VAR t =
    SUMMARIZE (
        'Table',
        'Table'[Customer],
        'Table'[ID],
        "Balance1", [Balance_1],
        "Balance2", [Balance_2],
        "Explanation_", [Explanation]
    )
RETURN
    SUMX (
        FILTER ( t, [Explanation_] = SELECTEDVALUE ( Explanation[Explanation] ) ),
        [Balance1]
    )
Delta_Sum = 
VAR t =
    SUMMARIZE (
        'Table',
        'Table'[Customer],
        'Table'[ID],
        "Balance1", [Balance_1],
        "Balance2", [Balance_2],
        "Explanation_", [Explanation],
        "Delta_", ABS ( [Balance_2] - [Balance_1] )
    )
RETURN
    SUMX (
        FILTER ( t, [Explanation_] = SELECTEDVALUE ( Explanation[Explanation] ) ),
        [Delta_]
    )

 

4. Create a Table visual like so:

explain.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@Anonymous , Create two tables like this

 

Version 1 = distinct(Table[Version])

Version 2 = distinct(Table[Version])

Do not join it with table back

 

Try like

Balanace_1 = 
var _max = allselected(Version1[Version]) // or Values(Version1[Version])) // or selectedvalues(Version1[Version]))
return
calculate(sum(Table[Balance]),Table[Version] in _max)


Balanace_2 = 
var _max = allselected(Version2[Version]) // or Values(Version1[Version])) // or selectedvalues(Version1[Version]))
return
calculate(sum(Table[Balance]),Table[Version] in _max)


diff =
Switch(Ture(),
[Balanace_1] - [Balanace_2] =0 ,"No Change",
[Balanace_1] - [Balanace_2] >0 ,"Increase",
[Balanace_1] - [Balanace_2] <0 ,"Decrease",
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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