Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SuddenClarity
Helper I
Helper I

Getting an error when trying to set a To and From date as a parameter in my report - Report Builder

I am importing data into Report Builder using a dataset. 

 

I am a bit unfamilar with DAX Querying, so I used the Query Designer and dragged in Client ID, Client Name, and Total Sales into the query. I also want the user to be able to choose between two date, so I dragged in the Date column from the Calendar table into the parameters section and checked off both parameter boxes for the From and To date. 

 

The result is the following query :

 

DEFINE
    VAR vFromCalendarDate1 =
        IF (
            PATHLENGTH ( @FromCalendarDate ) = 1,
            IF ( @FromCalendarDate <> "", @FromCalendarDate, BLANK () ),
            IF (
                PATHITEM ( @FromCalendarDate, 2 ) <> "",
                PATHITEM ( @FromCalendarDate, 2 ),
                BLANK ()
            )
        )
    VAR vFromCalendarDate1ALL =
        PATHLENGTH ( @FromCalendarDate ) > 1
            && PATHITEM ( @FromCalendarDate, 1, 1 ) < 1
    VAR vToCalendarDate1 =
        IF (
            PATHLENGTH ( @ToCalendarDate ) = 1,
            IF ( @ToCalendarDate <> "", @ToCalendarDate, BLANK () ),
            IF (
                PATHITEM ( @ToCalendarDate, 2 ) <> "",
                PATHITEM ( @ToCalendarDate, 2 ),
                BLANK ()
            )
        )
    VAR vToCalendarDate1ALL =
        PATHLENGTH ( @ToCalendarDate ) > 1
            && PATHITEM ( @ToCalendarDate, 1, 1 ) < 1

EVALUATE
SUMMARIZECOLUMNS (
    'Sales'[Client_ID],
    'Client'[Client_Name],
    RSCUSTOMDAXFILTER (
        @ClientClient_Name,
        EqualToCondition,
        [Client].[Client_Name],
        String
    ),
    FILTER (
        VALUES ( 'Calendar'[Date] ),
        (
            vFromCalendarDate1ALL
                || 'Calendar'[Date]
                    >= DATEVALUE ( vFromCalendarDate1 ) + TIMEVALUE ( vFromCalendarDate1 )
        )
            && (
                vToCalendarDate1ALL
                    || 'Calendar'[Date]
                        <= DATEVALUE ( vToCalendarDate1 ) + TIMEVALUE ( vToCalendarDate1 )
            )
    ),
    "Total Sales", [Total Sales],
)

 

 

When I try to run the report, I see the parameter that I set up for the date as per the screenshot below:

SuddenClarity_0-1683826040323.png

However, after I select the date and click "View Report", I get an error:

 "Query (1, 74) DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values."

 

SuddenClarity_1-1683826123577.png

 

What I've done:

I've checked the parameter properties for the two date parameters, and both are already set to "Date/Time" as the type. Available values is set to None, and Default values is set to None as well. 

 

In PowerBI, this field was created using the CALENDAR() table function:

 

 

Calendar = 
    CALENDAR ( 
        DATE ( YEAR ( MIN(Claims[IncurredDateFormatted]) ), 1, 1),
        DATE ( YEAR ( MAX(Claims[IncurredDateFormatted]) ), 12, 31)
    )
        

 

 

So it should already be in datetime format. Does anyone know where my error is coming from?

 

0 REPLIES 0

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Kudoed Authors