Forum Discussion
JBHCSS
3 years agoFrequent Visitor
Find the difference between values in a group
I'm new to Power BI and I am struggling to figure out how to calculate the difference between values within a group. I want to calculate the difference between the amount for the values within a grou...
- 3 years ago
Hi JBHCSS ,
Try this:Dif = Var _project = MAX(Difference[PROJECT]) Var _bidAmount = MAX(Difference[BID AMOUNT]) Var _minBidAmount = CALCULATE(MIN(Difference[BID AMOUNT]),FILTER(all(Difference),Difference[PROJECT]=_project)) Var _diff = _bidAmount-_minBidAmount Return _diff
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Nathaniel_C
Community Champion
3 years agoHi JBHCSS ,
So did you create a table called Difference? This is what I did in Power Query, and the wrote the measure in Power BI. Do you know how to insert this code?
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY9fC4IwFMW/yhg9jphTNB8tKAqiqAcfxIdhN432J6b1+btOUqSXnXs5v52dFQXN1KuRlNFFEIQoR/s2nXwYANfiGtCSzZgUJbfqDr0r5q7gHOUiNZ6ht9bQDfcY5wEOJ3fDXLKxY/REiDjG4bAkmVJgxvQJSKKkj7fVk2ytq+HvFcFWvP9DZmpQLSN7U+EWeWYntfZQ6kue5Qe0bDtwY5OR+JXNrcG25IpcM9Qpvw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PROJECT = _t, #"BID AMOUNT" = _t, COMPANY = _t, RANK = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"PROJECT", type text}, {"BID AMOUNT", Currency.Type}, {"COMPANY", type text}, {"RANK", Int64.Type}})
in
#"Changed Type"
Try this, and then you can substitute your own table.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel