Forum Discussion
Condition based dax situation
- 3 years ago
Hi Jatin77 ,
You can try this method:
O/p = VAR _BlankT = CALCULATE ( MAX ( 'Table'[test date] ), FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) ) ) VAR _BlankC = CALCULATE ( MAX ( 'Table'[test date] ), FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) ) ) VAR _CountT = CALCULATE ( COUNTA ( 'Table'[test date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ) VAR _CountC = CALCULATE ( COUNTA ( 'Table'[check date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ) VAR _TotalCountID = CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ) RETURN SWITCH ( TRUE (), _BlankC = BLANK () && _BlankT = BLANK (), "test pending", _CountT <> _TotalCountID || _CountC <> _TotalCountID, "retake the test", _CountT = _TotalCountID && _CountC = _TotalCountID && 'Table'[check date] <= 'Table'[test date], "check pending", BLANK (), "N/A" )The result is:
Hope this helps you.
Here is my PBIX file.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello ERD ,
Thank you for the reply. I have updated the data and made slight changes as well. I have also tried the dax which you have mentioned. Sharing the dax and o/p I'm getting:
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
--> o/p:
Thanks an Regards,
Jatin77
Hi Jatin77 ,
You can try this method:
O/p =
VAR _BlankT =
CALCULATE (
MAX ( 'Table'[test date] ),
FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
)
VAR _BlankC =
CALCULATE (
MAX ( 'Table'[test date] ),
FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
)
VAR _CountT =
CALCULATE ( COUNTA ( 'Table'[test date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) )
VAR _CountC =
CALCULATE ( COUNTA ( 'Table'[check date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) )
VAR _TotalCountID =
CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[ID] ) )
RETURN
SWITCH (
TRUE (),
_BlankC = BLANK ()
&& _BlankT = BLANK (), "test pending",
_CountT <> _TotalCountID
|| _CountC <> _TotalCountID, "retake the test",
_CountT = _TotalCountID
&& _CountC = _TotalCountID
&& 'Table'[check date] <= 'Table'[test date], "check pending",
BLANK (), "N/A"
)
The result is:
Hope this helps you.
Here is my PBIX file.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Jatin773 years ago
Helper I
Hi v-yinliw-msft,
Thank you for the reply. This solution worked on sample data but in original data, there's an additional condition occcured i.e. the o/p column says - "blank" if "test date and check date both are blank" or ""test date and check date both have a date" wherein blanks should only come for the condition if "check date>test date"
Thanks and Regards,
Jatin77 - Jatin773 years ago
Helper I
I have one more similar kind of a situation like -I have two more columns named "status" which have yes or no or blanks and "color" which have either yellow/blue
I want to calculate the no of distinct id's for following condition -
Color: yellow
Date: 11/01/2015And in the status column "yes" should be there for all the subjects, if for that id, any of the subject has any other value then it should not select that id
** The selected distinct id's should have "yes" for all the subjects **