Forum Discussion

Domenick's avatar
Domenick
Helper IV
6 years ago

IF function not working with Measure?

I'd like to compare a field to a calculated field, but I'm getting an error I don't quite understand:

     "A calculated column or RLS expression on a DirectQuery table cannot reference tables from a different data source"

 

Here is what I'm trying to accomplish:

I want to compare a field [DATE] in my table to a specific [DATE] field that has been determined in another calculation.

In the other calculation, I basically needed to find the MAX [DATE] where an associated field was "Yes." I essentially want to be able to create a new field that follows the logic: If([MostRecentlyApprovedDate]<=[DATE],"Yes","No")

 

 

5 Replies

  • edhans's avatar
    edhans
    Community Champion

    Direct Query models have a number of limitations and should be used sparingly. I think what the error is saying is your [MostRecentlyApprovedDate] measure and [Date] measure are from two different sources, and you cannot do that with a direct query model. You can with an import.

     

    Can you confirm the tables used in each of those measures are, in fact, from different sources?

    See this for limitations on DQ. It may be this one that is biting you:

     

    "Limitations are placed on DAX expressions allowed in measures to ensure that queries sent to the underlying data source have acceptable performance."

     

    It may cause performance issues to have the model try to send two different direct query commands to two different sources and combine into a single measure for comparison like you are trying to do.

    • Domenick's avatar
      Domenick
      Helper IV

      Yes, the measure [MostRecentlyApprovedDate] relies on a data field that is in another table. I can't really avoid that; it's a relational database.

       

      One workaround, I suppose, would be to join the tables before importing them. This would have been easy to do from the beginning, but I put a little too much faith in PowerBI. To do it now, would mean rebuilding everything from scratch. So it would be nice to be able to not have these

      • edhans's avatar
        edhans
        Community Champion

        It isn't another table. It mean another source. So two tables from one database are one source (or should be) but two tables from two different databases are two sources, and you cannot join those in Power Query if you are in Direct Query mode.