cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Robbinsbk
Regular Visitor

Add a calculated column to a Matrix visualization

I am using a Power Bi matrix visualization to display a series of data. I have two datasources.  The first is my data I want to display and the second is my target values.  There is a Mant to One relationship between my source data and my target data.  Power BI piked up the relationship when I imported the data. 2020-02-26_16-10-41.gif

 

I add to my source data a new column that is simply two of the colmns add together.  I add a second column which is the target from second table.  There are no slicers for filtering.  The data in the first two columns displays correctly.

 

I want to add a 3rd column that is my new column(named Target) - my new column(named SuperMarket WIP)  

This is my issue is doesn't display the correct amount.  It only gives me the options to choose the agregate functions.  As you can see from my snapshot, the calculation isn't what I am looking for.  My expectation are on the first row for example the new column (named Count of Gap) is 27 I expected - 3

 

SuperMarket WIP = (SuperMarketData[Before SuperMarket] + SuperMarketData[In SuperMarket])
Target = RELATED(TargetData[TARGET])
 
I believe it is related to filtering but can't figure the correct format.
 
I have tried a couple different scenarios
 
Gap = SuperMarketData[Target] - SuperMarketData[SuperMarket WIP]
 
Gap = RELATED(TargetData[TARGET] - (SuperMarketData[Before SuperMarket] + SuperMarketData[In SuperMarket])
 
Gap = RELATED(TargetData[TARGET]) - CALCULATE(SUMX(SuperMarketData, SuperMarketData[Before SuperMarket] + SuperMarketData[In SuperMarket]),FILTER(SuperMarketData, SuperMarketData[Die Type] = RELATED(TargetData[DIE_TYPE])))
 
Any help or suggestions would be greatly appreciated.
 
Thank you.
1 ACCEPTED SOLUTION

Accepted Solutions
Robbinsbk
Regular Visitor

Re: Add a calculated column to a Matrix visualization

Got it to work.  (Used a new name) What I did was use a measure.  I only wanted one value for the target. The relationship is Many to One.  Since there is only one value in the target type for each category I used MIN (again because there is only one value I could have just as easily used MAX) instead of sum for the target.

 

To Be Released = CALCULATE( MIN(SuperMarketData[Target]),ALLSELECTED(TargetData)) - CALCULATE( SUM(SuperMarketData[Before SuperMarket]) + SUM(SuperMarketData[In SuperMarket]),ALLSELECTED(TargetData))
 
2020-02-27_9-35-43.gif

 

 

View solution in original post

4 REPLIES 4
Super User IV
Super User IV

Re: Add a calculated column to a Matrix visualization

OK, a lot going on here, need sample data in text format and then what you expect in your new column and why. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


---------------------------------------

Not the Power BI thought police...

I have NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Tad17 Solution Sage
Solution Sage

Re: Add a calculated column to a Matrix visualization

Is your "GAP" column in the matrix a calculated column or a measure? Make sure it is a calculated column and then select SUM as the aggregation.

 

If this helps please kudo.

If this solves your problem please accept it as a solution.

Robbinsbk
Regular Visitor

Re: Add a calculated column to a Matrix visualization

Yes, it is a calculated column.  I tried a couple different calculations but none is working.

 

Gap = SUM(SuperMarketData[Target]) - SUM(SuperMarketData[SuperMarket WIP])
Gap = CALCULATE(SUM(SuperMarketData[SuperMarket WIP]) - SUM(SuperMarketData[Target]))

Gap = CALCULATE(SUM(SuperMarketData[Target]) - SUM(SuperMarketData[SuperMarket WIP]),FILTER(SUMMARIZE(SuperMarketData,SuperMarketData[Die Type]),SuperMarketData[Die Type]=RELATED(TargetData[DIE_TYPE])))
 
Robbinsbk
Regular Visitor

Re: Add a calculated column to a Matrix visualization

Got it to work.  (Used a new name) What I did was use a measure.  I only wanted one value for the target. The relationship is Many to One.  Since there is only one value in the target type for each category I used MIN (again because there is only one value I could have just as easily used MAX) instead of sum for the target.

 

To Be Released = CALCULATE( MIN(SuperMarketData[Target]),ALLSELECTED(TargetData)) - CALCULATE( SUM(SuperMarketData[Before SuperMarket]) + SUM(SuperMarketData[In SuperMarket]),ALLSELECTED(TargetData))
 
2020-02-27_9-35-43.gif

 

 

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors