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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BARN_SOAR
Regular Visitor

SQL Query to Power BI

I'm trying to replicate a table created by a SQL Query in DAX with a Computed Table. I'm getting the error "A Function 'PLACEHOLDER' has been used in a True/False expression that isused as a table filter expression. This is not allowed."

 

If anyone's able to review the original SQL code and give feedback on my attempts at replicating in DAX, it would be much appreciated!

 

Here's the original SQL Code:

SELECT Left([KMS],2) AS YearOfRec, [Table].KMS AS [Number of Reports], Count([Table].RecommendationNumber) AS [Number of Unimplemented Recommendations], Sum(IIf([PriorPeriodAdj]<>0 And [PriorPeriodAdjDate]<[Forms]![frm_SummaryTableSAR]![Text_PeriodStart],QCAdjusted([Questioned],[PriorPeriodAdj]),[Questioned])) AS QuestionedCostA, Sum([Table].BetterUse) AS SumOfBetterUse, Sum([Table].QuestionedSustained) AS SumOfQuestionedSustained, [Table].ResolutionDate

 

FROM [Table]

 

WHERE

(

(

([Table].KMS) Like "??-1-???" Or ([Table].KMS) Like "??-2-???" Or ([Table].KMS) Like "??-3-???" Or ([Table].KMS) Like "??-6-???") 

)

AND (([Table].ActIssueDate)<=Forms!frm_SummaryTableSAR!Text_PeriodStart)

AND (([Table].FinalActionDate) Is Null)

AND (([Table].Rec_Status_Text)<>"NoLongerApplicable")

)

OR

(

(

(

([Table].KMS) Like "??-1-???" Or ([Table].KMS) Like "??-2-???" Or ([Table].KMS) Like "??-3-???" Or ([Table].KMS) Like "??-6-???") 

)

AND (([Table].ActIssueDate)<=Forms!frm_SummaryTableSAR!Text_PeriodStart)

AND (([Table].FinalActionDate)>Forms!frm_SummaryTableSAR!Text_PeriodEnd)

AND (([Table].Rec_Status_Text)<>"NoLongerApplicable")

)

)


GROUP BY Left([KMS],2), [Table].KMS, [Table].ResolutionDate;

 

I've done the following in Power Query:

1. Created the Table

2. Created a computed column "Report Title FY" to replace LEFT([KMS],2)

3. Created a computed column "Report Type" to replace (KMS) Like "??-X-???"

 

Then, in Power BI, I:

4. To replace [Forms]![frm_SummaryTableSAR]![Text_PeriodStart]

created measure:

SAR_START = LOOKUPVALUE(
SAR_Period_DateDim[SAR_Period_Start],
SAR_Period_DateDim[SAR_Period],
SELECTEDVALUE(SAR_Period_DateDim[SAR_Period])
)
 

5. To replace Sum(IIf([PriorPeriodAdj]<>0 And [PriorPeriodAdjDate]<[Forms]![frm_SummaryTableSAR]![Text_PeriodStart],QCAdjusted([Questioned],[PriorPeriodAdj]),[Questioned])) AS QuestionedCostA

created measure:

SummaryA_CalcTable_QuestionedCostA = IF(

MIN('All Projects wRecs'[Prior Period Adj Date])< SAR_Period_DateDim[SAR_START]
&&
MIN('All Projects wRecs'[Prior Period Adjustment]) <> 0,
SUMX('All Projects wRecs',[Sum of Questioned Costs] + [Sum of Prior Period Adj]),
SUM('All Projects wRecs'[Sum of Questioned Costs])

)

 

6. To replace Forms!frm_SummaryTableSAR!Text_PeriodEnd

created measure:

SAR_END = LOOKUPVALUE(
SAR_Period_DateDim[SAR_Period_End],
SAR_Period_DateDim[SAR_Period],
SELECTEDVALUE(SAR_Period_DateDim[SAR_Period])
)
 
Here's the DAX code I've tried to replace the SQL query:
 
SummaryA_CalcTable = CALCULATETABLE(
FILTER (
'Table',
AND (
SUMMARIZE(
'Table',
[Report Title FY],
[KMS],
[Resolution Date],
"Number of Unimplemented Recommendations", COUNT('Table'[RecommendationNumber]),
"SumOfBetterUse", SUM('Table'[BetterUse]),
"SumOfQuestionedSustained", SUM('Table'[QuestionedSustained])
),
ADDCOLUMNS(
'Table', "QuestionedCostA", [SummaryA_CalcTable_QuestionedCostA]
)
)
),
//To replicate the WHERE statement in SQL
'Table'[Report Type] IN {1,2,3,6},
'Table'[ActIssueDate] <= [SAR_START],
'Table'[Rec Status Text] <> "NoLongerApplicable",
OR(ISBLANK('Table'[Final Action Date]),'Table'[Final Action Date] > [SAR_END])
)
 
For some additional background, I already tried to create what I need in Power Query
using Dynamic M query parameters. However, it seems like those only work with Direct Query.
So I tried to replicate the Table with Direct Query, but it had transformations which are not supported in
Direct Query.
1 REPLY 1
lbendlin
Super User
Super User

The error message is giving you the guidance on how to fix it.  Work on defangling your filter statement. Remove all filters and then add them in one by one to see where it breaks.  You will also be able to use variables to work around the "multiple sources" issue.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.