Forum Discussion
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.
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
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))
4 Replies
- Greg_DecklerCommunity Champion
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
- AnonymousNot applicable
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.
- RobbinsbkRegular Visitor
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])))- RobbinsbkRegular Visitor
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))