cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Highlighted
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,

1 REPLY 1
Highlighted
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,

Helpful resources

Announcements
Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

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