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 Community
I am relatively new to DAX - and hoping to get some help on this calculation (before I go back to SQL 🙂 ) I am trying to create a dynamic calculation for Nomincal vs Constant dollars based on multiple rates.
I have 2 main formulas (but is not applying the way I was hoping)
RateLookup2017 = SWITCH(VALUES('Escalation'[Escalation]),"Material 1", LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 1"),"Material 2",LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 2"),"Material 3",LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 3"),1)
2017 Dynamic = IF(HASONEFILTER('Escalation'[Escalation]), SWITCH( VALUES('Escalation'[Escalation]), "Constant", CALCULATE(Sum(Data[Amount]),Data[Year] IN {2017} ), "Nominal", [RateLookup2017]*CALCULATE(SUM(Data[Amount]),Data[Year] IN {2017} ) ,BLANK()),Blank())
MdxScript(Model) (14, 238) Calculation error in measure 'Measures 1'[RateLookup2017]: Function 'SWITCH' does not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.
OS Version:
Solved! Go to Solution.
Unfortunatly that didn't work with LOOKUPVALUE() function.......I just went back to IF as a Calculated Column which works fine.
Constant Amount = IF (AND(Data[Category] = "Material 1",Data[Year]=2017), LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 1")*[Amount], IF (AND(Data[Category] = "Material 2",Data[Year]=2017), LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 2")*[Amount], IF (AND(Data[Category] = "Material 3",Data[Year]=2017), LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 3")*[Amount], IF (AND(Data[Category] = "Material 1",Data[Year]=2018), LOOKUPVALUE('Escalation Rates'[2018],'Escalation Rates'[Category],"Material 1")*[Amount], IF (AND(Data[Category] = "Material 2",Data[Year]=2018), LOOKUPVALUE('Escalation Rates'[2018],'Escalation Rates'[Category],"Material 2")*[Amount], IF (AND(Data[Category] = "Material 3",Data[Year]=2018), LOOKUPVALUE('Escalation Rates'[2018],'Escalation Rates'[Category],"Material 3")*[Amount], IF (AND(Data[Category] = "Material 1",Data[Year]=2019), LOOKUPVALUE('Escalation Rates'[2019],'Escalation Rates'[Category],"Material 1")*[Amount], IF (AND(Data[Category] = "Material 2",Data[Year]=2019), LOOKUPVALUE('Escalation Rates'[2019],'Escalation Rates'[Category],"Material 2")*[Amount], IF (AND(Data[Category] = "Material 3",Data[Year]=2019), LOOKUPVALUE('Escalation Rates'[2019],'Escalation Rates'[Category],"Material 3")*[Amount], 0 )))))))))
@Jim_brower this DAX seems need attention:
RateLookup2017 = SWITCH(TRUE(), "Material 1", LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 1"), "Material 2", LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 2"), "Material 3", LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 3"),1)
Highlighted above should return True/False value whereas you just have static value.
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.
Thanks - I updated to values - not sure if that is correct.
@Jim_brower i guess you updated the measure in original post. Did it worked? It should be fine thou.
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.
Unfortunatly that didn't work with LOOKUPVALUE() function.......I just went back to IF as a Calculated Column which works fine.
Constant Amount = IF (AND(Data[Category] = "Material 1",Data[Year]=2017), LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 1")*[Amount], IF (AND(Data[Category] = "Material 2",Data[Year]=2017), LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 2")*[Amount], IF (AND(Data[Category] = "Material 3",Data[Year]=2017), LOOKUPVALUE('Escalation Rates'[2017],'Escalation Rates'[Category],"Material 3")*[Amount], IF (AND(Data[Category] = "Material 1",Data[Year]=2018), LOOKUPVALUE('Escalation Rates'[2018],'Escalation Rates'[Category],"Material 1")*[Amount], IF (AND(Data[Category] = "Material 2",Data[Year]=2018), LOOKUPVALUE('Escalation Rates'[2018],'Escalation Rates'[Category],"Material 2")*[Amount], IF (AND(Data[Category] = "Material 3",Data[Year]=2018), LOOKUPVALUE('Escalation Rates'[2018],'Escalation Rates'[Category],"Material 3")*[Amount], IF (AND(Data[Category] = "Material 1",Data[Year]=2019), LOOKUPVALUE('Escalation Rates'[2019],'Escalation Rates'[Category],"Material 1")*[Amount], IF (AND(Data[Category] = "Material 2",Data[Year]=2019), LOOKUPVALUE('Escalation Rates'[2019],'Escalation Rates'[Category],"Material 2")*[Amount], IF (AND(Data[Category] = "Material 3",Data[Year]=2019), LOOKUPVALUE('Escalation Rates'[2019],'Escalation Rates'[Category],"Material 3")*[Amount], 0 )))))))))
here is another post using switch with tru.
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 |
---|---|
109 | |
95 | |
77 | |
65 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |