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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate not working

Hi,

 

We are trying to replicate our SQL Server reports in powerbi.

 

One of the calculations works out awaiting orders.

Select NA1.WAREHOUSE_CODE,
COUNT(DISTINCT NA1.SALES_DOCUMENT_NUM) AS CanFulfill
INTO #CanFulfill
FROM #NewAwaiting NA1
WHERE (SELECT SUM(NA2.BACKORDERED) FROM #NewAwaiting NA2 WHERE NA1.SALES_DOCUMENT_NUM = NA2.SALES_DOCUMENT_NUM) = 0
AND NA1.SALES_RQD_QUANTITY > 0
GROUP BY NA1.WAREHOUSE_CODE
ORDER BY NA1.WAREHOUSE_CODE

 However if we try

Awaiting = CALCULATE(DISTINCTCOUNT(Query1[SALES_DOCUMENT_NUM]),sum(Query1[BACKORDERED])=0, Query1[SALES_RQD_QUANTITY]>0)

 

It comes back saying cant use sum in a true false.

 

What is the best way to do this?

 

Thanks

1 REPLY 1
HotChilli
Super User
Super User

It's quite challenging to get an answer from this information.  It relies on knowing advanced SQL and then creating a mental model in one's head then trying to convert that to a powerbi model.

 

The above 2 queries aren't doing the same thing anyway.  The SQL returns a temp table with 2 columns after doing a self-join on another temp table.  We don't know if Awaiting is a column or measure.

It worries me that the powerbi table is called Query1, rather than Sales or something like that.

I suggest that you post some data and desired output with an explanation of your model and whether you want a calculated column or measure.  Someone will help you.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.