cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AshPower Frequent Visitor
Frequent Visitor

SQL query to DAX

Looking to convert this SQL query in DAX. Any help is much appreciated.

 

select phonemodel,CreationDate,sum([Failed])
FROM [DVDB].[dbo].[DailyStatus]
where CreationDate = (select max(CreationDate) FROM [DVDB].[dbo].[DailyStatus])
group by phonemodel,CreationDate

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-sihou-msft
Moderator

Re: SQL query to DAX

@AshPower

 

You can write DAX like below:

 

EVALUATE
VAR MaxDate =
    CALCULATE ( MAX ( DailyStatus[CreationDate] ) )
RETURN
    FILTER (
        SUMMARIZE (
            DailyStatus,
            DailyStatus[phonemodel],
            DailyStatus[CreationDate],
            "Total Failed", SUM ( DailyStatus[Failed] )
        ),
        [CreationDate] = MaxDate
    )

Please also refer to article below:

 

https://www.sqlbi.com/articles/from-sql-to-dax-filtering-data/

 

Regards,

View solution in original post

1 REPLY 1
Moderator v-sihou-msft
Moderator

Re: SQL query to DAX

@AshPower

 

You can write DAX like below:

 

EVALUATE
VAR MaxDate =
    CALCULATE ( MAX ( DailyStatus[CreationDate] ) )
RETURN
    FILTER (
        SUMMARIZE (
            DailyStatus,
            DailyStatus[phonemodel],
            DailyStatus[CreationDate],
            "Total Failed", SUM ( DailyStatus[Failed] )
        ),
        [CreationDate] = MaxDate
    )

Please also refer to article below:

 

https://www.sqlbi.com/articles/from-sql-to-dax-filtering-data/

 

Regards,

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 6 members 1,017 guests
Please welcome our newest community members: