Forum Discussion
Sri57
2 years agoFrequent Visitor
DAX Query
I have created a dax query to get count of names, considering both the current fiscal year and potentially the previous fiscal year if no data exists for the current year.please find the following da...
- Anonymous2 years ago
Hi Sri57 ,
Try to modify your formula like below:
Adequate_FYTD_Audit_Session = VAR CurrentDate = MAX('Date'[Fiscal Year ID]) VAR SelectedSession = SELECTEDVALUE('Date'[Session]) VAR result = CALCULATE( COUNT('Audit'[ENGAGEMENT_NAME]), 'Audit'[RATING] = "Adequate" && 'Audit'[Session] = SelectedSession && 'Audit'[FISCAL_YEAR_ID] = CurrentDate ) VAR max_notblank = CALCULATE( MAX('Audit'[FISCAL_YEAR_ID]), FILTER( ALL('Audit'), 'Audit'[FISCAL_YEAR_ID] < CurrentDate && 'Audit'[Session] = SelectedSession && NOT ISBLANK('Audit'[FISCAL_YEAR_ID]) ) ) VAR result1 = CALCULATE( COUNT('Audit'[ENGAGEMENT_NAME]), 'Audit'[RATING] = "Adequate" && 'Audit'[Session] = SelectedSession && 'Audit'[FISCAL_YEAR_ID] = max_notblank ) RETURN IF(ISBLANK(result), result1, result)Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
2 years agoNot applicable
Hi Sri57 ,
Try to modify your formula like below:
Adequate_FYTD_Audit_Session =
VAR CurrentDate = MAX('Date'[Fiscal Year ID])
VAR SelectedSession = SELECTEDVALUE('Date'[Session])
VAR result =
CALCULATE(
COUNT('Audit'[ENGAGEMENT_NAME]),
'Audit'[RATING] = "Adequate" &&
'Audit'[Session] = SelectedSession &&
'Audit'[FISCAL_YEAR_ID] = CurrentDate
)
VAR max_notblank =
CALCULATE(
MAX('Audit'[FISCAL_YEAR_ID]),
FILTER(
ALL('Audit'),
'Audit'[FISCAL_YEAR_ID] < CurrentDate &&
'Audit'[Session] = SelectedSession &&
NOT ISBLANK('Audit'[FISCAL_YEAR_ID])
)
)
VAR result1 =
CALCULATE(
COUNT('Audit'[ENGAGEMENT_NAME]),
'Audit'[RATING] = "Adequate" &&
'Audit'[Session] = SelectedSession &&
'Audit'[FISCAL_YEAR_ID] = max_notblank
)
RETURN
IF(ISBLANK(result), result1, result)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.