cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
krzysztof
Helper III
Helper III

Matrix calculus - specific formula for matrix

Hi,
I want to calculate the difference in values between versions of files in matrix visualization. I tried to present it as simply as possible on a picture. I am also including the pbx file

 

2020-08-05_00h09_28.png

 

PBX 

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

Hi, @krzysztof 

 

You may create a calculated table and a measure as below.
Calculated table:

Table = DISTINCT(Arkusz1[File_Name])

 

Measure:

Result = 
IF(
    ISINSCOPE(Arkusz1[File_Name]),
    var _value1 = 
    CALCULATE(
        SUM(Arkusz1[Values]),
        FILTER(
            ALL(Arkusz1),
            Arkusz1[Company]=SELECTEDVALUE(Arkusz1[Company])&&
            Arkusz1[Category]=SELECTEDVALUE(Arkusz1[Category])&&
            Arkusz1[Week]=SELECTEDVALUE(Arkusz1[Week])&&
            Arkusz1[File_Name]=SELECTEDVALUE('Table'[File_Name])
        )
    )
    return
    _value1-SUM(Arkusz1[Values])
)

 

Finally you need to replace 'File_Name' column from 'Arkusz1' in 'Columns' area with 'File_Name' column from 'Table'.

e1.png

 

Best Regards

Allan

 

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-alq-msft
Community Support
Community Support

Hi, @krzysztof 

 

You may create a calculated table and a measure as below.
Calculated table:

Table = DISTINCT(Arkusz1[File_Name])

 

Measure:

Result = 
IF(
    ISINSCOPE(Arkusz1[File_Name]),
    var _value1 = 
    CALCULATE(
        SUM(Arkusz1[Values]),
        FILTER(
            ALL(Arkusz1),
            Arkusz1[Company]=SELECTEDVALUE(Arkusz1[Company])&&
            Arkusz1[Category]=SELECTEDVALUE(Arkusz1[Category])&&
            Arkusz1[Week]=SELECTEDVALUE(Arkusz1[Week])&&
            Arkusz1[File_Name]=SELECTEDVALUE('Table'[File_Name])
        )
    )
    return
    _value1-SUM(Arkusz1[Values])
)

 

Finally you need to replace 'File_Name' column from 'Arkusz1' in 'Columns' area with 'File_Name' column from 'Table'.

e1.png

 

Best Regards

Allan

 

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

MFelix
Super User
Super User

Hi @krzysztof ,

 

Create two disconnected table with the File Name and File_Name distinct values then add the following measure:

File_Values = 
CALCULATE (
    SUM ( Arkusz1[Values] ),
    FILTER (
        ALLSELECTED ( Arkusz1[File_Name] ),
        Arkusz1[File_Name] = SELECTEDVALUE ( File_Name[File_Name] )
    )
)
    - CALCULATE (
        SUM ( Arkusz1[Values] ),
        FILTER (
            ALLSELECTED ( Arkusz1[File Name] ),
            Arkusz1[File Name] = SELECTEDVALUE ( 'File Name'[File Name] )
        )
    )

Now setup your matrix in the following way:

  • Rows:
    • Arkusz1[Company]
    • Arkusz1[Category]
    • Arkusz1[Week]
    • File_Name[File_Name]
  • Columns
    • File Name[File Name] 
  • Values
    • [File_Values]

 

Check result in attach PBIX there are some plus and minus that are not correct not sure if is of your data or the calculation you made for the example but an easy fix for sure.

 
 
 
 

matrix.png


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors