The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hey Guys,
I'm trying to calculate the variance of units sold of a product based on period code, model, color, etc... Normaly I use the quick measure tool to handle this task but the way my table is setup, it wont allow me to.
This is what my table looks like, P2 being the latest time period, P1 being the previous time period.
Any help with this dax function would be greatly appreciated as I'm still getting familiar with dax calculations. Thank You!
Solved! Go to Solution.
@kennym9 So like this?
Measure =
VAR __Period = MAX('Table'[Period Code])
VAR __Model = MAX('Table'[Model)
VAR __Color = MAX('Table'[Color)
VAR __UnitsSold = MAX('Table'[Units Sold])
RETURN
IF(__Period = "P1", BLANK(), __UnitsSold - MAXX(FILTER(ALL('Table'),__Period = "P1" && [Model] = __Model && [Color] = __Color),[Units Sold]))
@kennym9 So like this?
Measure =
VAR __Period = MAX('Table'[Period Code])
VAR __Model = MAX('Table'[Model)
VAR __Color = MAX('Table'[Color)
VAR __UnitsSold = MAX('Table'[Units Sold])
RETURN
IF(__Period = "P1", BLANK(), __UnitsSold - MAXX(FILTER(ALL('Table'),__Period = "P1" && [Model] = __Model && [Color] = __Color),[Units Sold]))
User | Count |
---|---|
28 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
34 | |
15 | |
12 | |
7 | |
6 |