confused on the switch function
What is VAR and RETURN?
and what is the purpose of using SWITCH instead of using "MonthName", FORMAT([Date], "MMMM") when we are creating the table in the beginning?
Don't really understand the switch function
The SWITCH function can be seen as another IF/Else Statement. If we are to use If/Else Statement for MonthName the syntax will be very long something along the lines IF(Date[Month] = 1, "January",IF(Date[Month] = 2, "February", etc. With Swtich, we are only referencing the Month column once and we are calling out the values and assigning month name to each value. Yes, you are correct, this can be done using the FORMAT function, but inside a real work-case scenario, we import tables from databases and other data sources where we can build custom columns such as the case with the switch function.
VAR means variable, which is a value that can be reused multiple times inside our measures. Instead of calling SELECTEDVALUE(x,y,z) several times in our code, we can assign this function onto a variable and call this variable in our code multiple times to save ourselves some time and tidy up our code. RETURN is something that needs to be used with variables. if we declare a variable, Power BI does not know what to do with this value unless we have a RETURN statement and after the RETURN statement we reference the variable.
Let me know if this helps.
Thanks for the explanation, understood now. I hope you can update the videos as some functions were not really explained and jumped straight into applying.
Also, the sound for most of the videos were a bit soft, and im not able to adjust the volume any higher anymore, hope it can be fixed.