Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, trying to write a measure for Variance%. There are lots of Date, First, Last and Shop which need to be matched before proceed to calculate the Variance %. Column Status will only consist of "Quote", "Actual" and "Forecast". Calculation is shown at right, i.e. Variance % = Quote minus Actual then divide by Quote; Forecast minus Actual then divide by Forecast
Gurus out there, may you please help me!
Solved! Go to Solution.
so i would do this with two parts
1 - create a calculated colunm for Key that is a uniqu key for each iteration of date,last,first,shop
KEY = [Date] & "-" & [First] & "-" & [Last] & "-" & [Shop]
next create a measure as below
Measure = -- first define the key filed and status as veriables var k = max('Table'[KEY]) var s = max('Table'[Status]) -- then caluclate the actual, forecast and qoute var a = CALCULATE(sum('Table'[Value]), 'Table'[Status]= "actual", 'Table'[KEY] = k) var f = CALCULATE(sum('Table'[Value]), 'Table'[Status]= "Forecast", 'Table'[KEY] = k) var q = CALCULATE(sum('Table'[Value]), 'Table'[Status]= "Qoute", 'Table'[KEY] = k) -- then calculate each of the possable values var v1 = 0 var v2 = (a-f)/f var v3 = (a-q)/q --finaly switch values based on defined status var ret = SWITCH(s, "ACTUAL",v1, "FORECAST",v2, "QOUTE",v3,0) return ret
simple put the measure first defines the two dimensions the key and the status
it then calcualtes the actual, forecast and qoute for each of these dimentions and stores them in veriables
it then usees these three veriables to create a set of values based on your calculations
the final step then switches between each of these values based on the status in the row
Proud to be a Super User!
@parry2k , yes there is no common identifier.
@AnthonyTilley , you got it. This is what I want. New to DAX, will need to digest your solution. Thank you so much!
so i would do this with two parts
1 - create a calculated colunm for Key that is a uniqu key for each iteration of date,last,first,shop
KEY = [Date] & "-" & [First] & "-" & [Last] & "-" & [Shop]
next create a measure as below
Measure = -- first define the key filed and status as veriables var k = max('Table'[KEY]) var s = max('Table'[Status]) -- then caluclate the actual, forecast and qoute var a = CALCULATE(sum('Table'[Value]), 'Table'[Status]= "actual", 'Table'[KEY] = k) var f = CALCULATE(sum('Table'[Value]), 'Table'[Status]= "Forecast", 'Table'[KEY] = k) var q = CALCULATE(sum('Table'[Value]), 'Table'[Status]= "Qoute", 'Table'[KEY] = k) -- then calculate each of the possable values var v1 = 0 var v2 = (a-f)/f var v3 = (a-q)/q --finaly switch values based on defined status var ret = SWITCH(s, "ACTUAL",v1, "FORECAST",v2, "QOUTE",v3,0) return ret
simple put the measure first defines the two dimensions the key and the status
it then calcualtes the actual, forecast and qoute for each of these dimentions and stores them in veriables
it then usees these three veriables to create a set of values based on your calculations
the final step then switches between each of these values based on the status in the row
Proud to be a Super User!
@Anonymous do you have common identifier for each group or just name is the identifier to group rows together?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
99 | |
76 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |