Forum Discussion
Need some help with DAX
Error Message:
MdxScript(Model) (11, 118) Calculation error in measure 'StationList'[Measure]: Function 'SWITCH' does not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.
Power BI Formulas:
section Section1;
shared Gross = let
Source = Excel.Workbook(File.Contents("C:\Users\mani\Desktop\MS Power BI (2018)\Station Summarized.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"STATION", type text}, {"BUDGET", type number}, {"GROSS", type number}})
in
#"Changed Type";
Formlae I have used:
Measure = VAR SelectedGross = CALCULATE ([StnGross], INTERSECT ( VALUES ( Gross[STATION] ), VALUES ( StationList[STATION] ) ))
VAR UnSelectedGross = CALCULATE ( [StnGross], EXCEPT (ALL ( Gross[STATION] ), VALUES ( StationList[STATION] ) ) )
VAR AllGross = CALCULATE ( [StnGross], ALL ( 'Gross'[STATION] ) )
RETURN IF ( HASONEVALUE ( StationList[STATION] ), SWITCH ( VALUES ( StationList[STATION] ), "OTHER", SelectedGross , UnSelectedGross, AllGross))