Forum Discussion
yjk3140
3 years agoHelper I
Converting SQL into DAX...
Hi, I have written the sql query below SELECT count(job_id) FROM (SELECT distinct job_id,status,DENSE_RANK over() partition by job_id order by timestamp desc AS rn FROM table1) t2 WHERE t2.rn = 1 a...
- 3 years ago
Hi yjk3140
Final solution is as followsPaused Jobs = SUMX ( VALUES ( 'table1'[job_id] ), VAR MaxDate = CALCULATE ( MAX ( 'table1'[datetime1] ) ) VAR LastRecord = FILTER ( CALCULATETABLE ( 'table1' ), 'table1'[datetime1] = MaxDate && 'table1'[job_active_status] = "PAUSED" ) VAR Result = IF ( NOT ISEMPTY ( LastRecord ), 1 ) RETURN Result ) - 3 years ago
Anonymous
Ok, please tryCASH_IPD = COUNTROWS ( CALCULATETABLE ( SUMMARIZE ( BI_OSR_Revenues, BI_OSR_Revenues[Encounter_No], BI_OSR_Revenues[Payment_TypeName], BI_OSR_Revenues[InvoiceNo] ), BI_OSR_Revenues[Tran_Month] = 3, BI_OSR_Revenues[Tran_Year] = 2022, BI_OSR_Revenues[Payment_TypeName] = "CASH (IPD)", NOT ISBLANK ( BI_OSR_Revenues[admission_Date] ) ) )
Anonymous
3 years agoNot applicable
How to convert this SQL Code to Dax Measure
select count(Encounter_No) as CASH_IPD
from
(
select distinct
Encounter_No,
Payment_TypeName,
InvoiceNo
from BI_OSR_Revenues
where Tran_Month = 3 and Tran_Year = 2022
and Payment_TypeName = 'CASH (IPD)'
and isnull(admission_Date,'') <> ''
) as t1
tamerj1
3 years agoCommunity Champion
Anonymous
Please try
CASH_IPD =
COUNTROWS (
CALCULATETABLE (
VALUES ( BI_OSR_Revenues[Encounter_No] ),
BI_OSR_Revenues[Tran_Month] = 3,
BI_OSR_Revenues[Tran_Year] = 2022,
BI_OSR_Revenues[Payment_TypeName] = "CASH (IPD)",
NOT ISBLANK ( BI_OSR_Revenues[admission_Date] )
)
)- Anonymous3 years agoNot applicable
i did not get the right results because the sql query is having distinct fields
- tamerj13 years agoCommunity Champion
Anonymous
Ok, please tryCASH_IPD = COUNTROWS ( CALCULATETABLE ( SUMMARIZE ( BI_OSR_Revenues, BI_OSR_Revenues[Encounter_No], BI_OSR_Revenues[Payment_TypeName], BI_OSR_Revenues[InvoiceNo] ), BI_OSR_Revenues[Tran_Month] = 3, BI_OSR_Revenues[Tran_Year] = 2022, BI_OSR_Revenues[Payment_TypeName] = "CASH (IPD)", NOT ISBLANK ( BI_OSR_Revenues[admission_Date] ) ) )- Anonymous3 years agoNot applicable
Thank you is working perfectly😀