cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
mahg1kor
Frequent Visitor

Need help on convert Sql query to DaX

Hello All,

I have a sample data of sales which has applications, their categories and sales.

I need to calculate the distinct count of applications which has sales as zero or blank.


1Pc post.PNG
I have Sample data like the above picture, I need to calculate the count of applications
I have written the Sql Query But need help in converting it into DAX
 
select Application,Count(Application)as appcount, SUM(ISNULL([Actual Date],0)) from DWH.[Report Check Data]
Where IsDeleted=0
Group By Application having SUM(ISNULL([Actual Date],0))=0
Order By Application

when I tried the above query in sql i am getting the below output

5a2f2917-d9c4-4a37-94e4-7e0e129a393f.png


Can anyone please help me on this..

1 ACCEPTED SOLUTION

Hi @mahg1kor ,

 

According to your statement, I think your issue should be caused by that OR() function will return True or False result, you need to add it in FILTER() function.

_Modified Count of Actual date <0 =
CALCULATE (
    DISTINCTCOUNT ( 'Monitoring Report Check Data'[Application] ),
    FILTER (
        'Monitoring Report Check Data',
        OR ( ISBLANK ( [_SUM of actual date] ), [_SUM of actual date] = 0 )
    )
)

 

Best Regards,
Rico Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
mahg1kor
Frequent Visitor

@audreygerred 
Thanks for your response, I have tried your solution but giving the below error.

mahg1kor_0-1695657407405.png

I am expecting the result of Count of Application column from below sql query output which should be 3.
select Application,Count(Application)as appcount, SUM(ISNULL([Actual Date],0)) from DWH.[Report Check Data]
Where IsDeleted=0
Group By Application having SUM(ISNULL([Actual Date],0))=0
Order By Application

mahg1kor_1-1695657774258.png

Please help..

Hi @mahg1kor ,

 

According to your statement, I think your issue should be caused by that OR() function will return True or False result, you need to add it in FILTER() function.

_Modified Count of Actual date <0 =
CALCULATE (
    DISTINCTCOUNT ( 'Monitoring Report Check Data'[Application] ),
    FILTER (
        'Monitoring Report Check Data',
        OR ( ISBLANK ( [_SUM of actual date] ), [_SUM of actual date] = 0 )
    )
)

 

Best Regards,
Rico Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors