4 Replies Latest reply on Dec 3, 2018 11:38 PM by Satish Rao

    Weekdays in parameter

    Satish Rao

      Hi All,

      I need help to display sales per month, weekdays and days. I have converted the ship date into Months, and days through customs but was not able to convert into weekdays (as it gets into date part instead of date value) so I created a Calculated field (STR(DATEPART('weekday',[Ship Date]) <> 1 AND DATEPART('weekday',[Ship Date]) <> 7) and then have created a parameter. When I select months and days in parameter, the graph shows correct data, but when I add weekdays in calculated field it gives an error 'Expected type date, found string. Result type from Case expression much match'.

       

      Please suggest.

        • 1. Re: Weekdays in parameter
          Ritesh Bisht

          Hi Satish,

           

          You have to match the 'type' here.

           

          Can you paste your calculation here ? You need to convert something to date here at case statement

           

          Thanks,

          Ritesh

          • 2. Re: Weekdays in parameter
            Satish Rao

            Thanks Ritest for looking into it.

             

            I created custom dates of shipping date. For month, Days, years and weekday. But for weekday, when i try to convert, it gets into Date Part and not Date Value.

             

            So, when I create a parameter as:

             

            CASE [Date level selector]

            WHEN 'Month' THEN [Ship Date (Months)]

            WHEN 'Days' Then [Ship Date (Days)]

            When 'Year' THEN [Ship Date (Years)]

            WHEN 'Weekdays' Then [Ship Date (Weekdays)]

            END

             

            Expected type date, found string. REsult type from case expression must match.

             

            Then I created a calculated field as

             

            CF_Weekdays - STR(DATEPART('weekday',[Ship Date]) <> 1 AND DATEPART('weekday',[Ship Date]) <> 7)

            and used it in parameter.

            CASE [Date level selector]

            WHEN 'Month' THEN [Ship Date (Months)]

            WHEN 'Days' Then [Ship Date (Days)]

            When 'Year' THEN [Ship Date (Years)]

            WHEN  'Weekday' Then [CF_Weekdays]

            END

            error- Expected type date, found string. REsult type from case expression must end.

            • 3. Re: Weekdays in parameter
              Rahul Patil

              Hi Satish,

               

              Please use the following calculations!

               

              CASE [Date Level Selector]

              WHEN 'Months' THEN (STR(DATEPART('month', [Ship Date])))

              WHEN 'Days' Then (STR(DATEPART('day', [Ship Date])))

              When 'Year' THEN ( STR(DATEPART('year', [Ship Date])))

              WHEN 'Weekdays' Then (STR(DATEPART('weekday', [Ship Date])))

              END

               

              If you wish your parameter to show "Weekday" & "Month" names to be shown, then i suggest you to please use the following calculations and place it in the output for "Weekdays" & "Months" in above calculation,

               

              For Months --> Create a calculated field with the name "Months" and write the logic as follows,

              case STR(DATEPART('month',[Ship Date]))

              when '1' then 'January'

              when '2' then 'February'

              .

              .

              .

              When '12' then 'December'

              END

               

              Similary write one calculated field for "Weekday"

               

              Hope this helps

              1 of 1 people found this helpful
              • 4. Re: Weekdays in parameter
                Satish Rao

                Thank you Sir. This helped me.