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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
marcos_osorio
Helper II
Helper II

Difference between to types in collum with measures

Hi, I have a question to know if it is possible to do it.

 

I have a matrix with several measures in the rows, this measures divides in two types, Result and Budget.

Ex:                  Result        Budget

Measure 1

Measure 2

Measure 3

 

Is there a way to calculate the diff between the two types without making the "Measure 1 result" - "Measure 1 Budget"? so to avoid duplicating all measures?

Thank you very much.

3 REPLIES 3
Dhacd
Resolver III
Resolver III

Good day @marcos_osorio,
Since you haven't shared any data source and the desired outcome I have assumed one which can be found below.

Source Data:

Expenditure

Status

Amount

Internal

Result

150

Internal

Budget

200

External

Result

250

External

Budget

300


Expected Outcome:

Now, this can be implemented by using a single measure and adding another table to the Power BI.

If you believe this is the desired output, please follow along else please share dummy data for the input and output.

First, you need to load another table as below (This can be implemented using a power query or excel).

Switch Table:

Status

Sort

Result

1

Budget

2

Difference

3

Now we have 2 tables in the data model Source Data and Switch Table,

Add a matrix visual to the page and in the column, headers add expenditure from the Source data table, and to the row, headers add Status from the switch table. Now since there is no relationship between these tables you will be getting an error.

We are not creating any relationship but creating a measure and adding an inbuilt filter context by using a conditional function. (Both if and switch will be working)

Here I used a Switch statement to provide the result.

Values = SWITCH(TRUE(),

                      SELECTEDVALUE('Switch Table'[Status]) = "Result",

                          CALCULATE(sum('Source Data'[Amount]),'Source Data'[Status]="Result"),

                      SELECTEDVALUE('Switch Table'[Status]) = "Budget",

                          CALCULATE(sum('Source Data'[Amount]),'Source Data'[Status]="Budget"),

                      SELECTEDVALUE('Switch Table'[Status]) = "Difference",
                          CALCULATE(sum('Source Data'[Amount]),'Source Data'[Status]="Budget")-CALCULATE(sum('Source Data'[Amount]),'Source Data'[Status]="Result")

)

Now add this measure to the values field in the matrix and you will get the result.

Measure Explanation: The switch statement will be checking the row level of the status in the switch table and according to that the calculate function will be the calculating the sum with the desired filter context from the source table.

And if you think this helps you please mark this reply as an answer so it will be useful for more users.
Thanks and regards,
Atma.

v-kkf-msft
Community Support
Community Support

Hi @marcos_osorio ,

 

Could you please share your data, formula and expected output?

 

Best Regards,
Winniz

speedramps
Super User
Super User

We want to help. Please try give a better decsription. This one looks a bit rushed. ☹️

Provide a copy of input data as a table (not a screen shot) so we can import it and develop a solutuion.

Also provide an example of the desired output with clear description. 

Hide any private date.

Thanks 😀😀

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.