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
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
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,