Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi, @tamerj1
@johnt75 @parry2k @Jihwan_Kim @ThxAlot @VahidDM
I am trying to create a DAX for the below case:-
IF ( (I:O createddate) > Case Completion Date), then
(I:O createddate) - Case Completion Date,
ELSE NULL)
I have created a DAX -
@johnt75 @parry2k @Jihwan_Kim @ThxAlot @VahidDM
can someone please help on this?
Hi @Amitkr174
I can tell that [CreatedDate] and [Case_Comp_date] are columns not measures and [Comp_Created_datediff] is a calculated column (summarized by sum) and not a measure as the total sums the individual values of the rows. Please confirm. I can also notice that both date columns are of text data type as they are alligned left.
However, what is confusing me is how the subtraction is actually calculating correct difference. Do you have other date columns of date data type?
Yes, columns [CreatedDate] and [Case_Comp_date] are not measures. [Comp_Created_datediff] is a measure DAX is -
IF([CreatedDate]>[Case_Comp_date],
[Comp_Created_datediff] is most likely a calculated column. Please double check. The DAX that you have provided would result in an error if used in a measure.
It is important to have accurate information about the problem in order to be able to solve it.
yes, you are correct, it is a calculated column.
Condition is - if Createddate>CaseCompdate,then Createddate-CaseCompdate,else NULL.
It should stop once Createddate>CaseCompdate is true, rest of the lines in the column should be blank. Output sample is attached.
Please try
=
IF (
'Table'[CreatedDate] > 'Table'[Case_Comp_date]
&& CALCULATE (
MIN ( 'Table'[CreatedDate] ),
ALLEXCEPT ( 'Table', 'Table'[Opp_DealR], 'Table'[CaseNumber] )
) = 'Table'[CreatedDate],
'Table'[CreatedDate] - 'Table'[Case_Comp_date]
)
Below is the result I am getting- Measure 4. I am not able to change the format as well. Please advise.
=
IF (
'Table'[CreatedDate] > 'Table'[Case_Comp_date]
&& CALCULATE (
MIN ( 'Table'[CreatedDate] ),
ALLEXCEPT ( 'Table', 'Table'[Opp_DealR], 'Table'[CaseNumber] )
) = 'Table'[CreatedDate],
INT ('Table'[CreatedDate] - 'Table'[Case_Comp_date] )
)
Thanks @tamerj1 - it is working fine for one Deal Number but when I am selecting another one it is getting blank.
When I select DR3630255, it is not showing in the first table though it has a Createddate > Case Comp date i.e. 18th May. Please advise.
Calculated columns do not interact with the filter context. This has to be a measure
=
VAR T =
ALLSELECTED ( 'Table' )
RETURN
MAXX (
'Table',
IF (
'Table'[CreatedDate] > 'Table'[Case_Comp_date]
&& CALCULATE (
MIN ( 'Table'[CreatedDate] ),
T,
VALUES ( 'Table'[Opp_DealR] ),
VALUES ( 'Table'[CaseNumber] )
) = 'Table'[CreatedDate],
INT ( 'Table'[CreatedDate] - 'Table'[Case_Comp_date] )
)
)
Still same issue is there.
@Amitkr174
Apologies, your reply was overlooked somehow. Yes you are right there was a typo mistake.
Please try
=
VAR T =
ALLSELECTED ( 'Table' )
RETURN
MAXX (
T,
IF (
'Table'[CreatedDate] > 'Table'[Case_Comp_date]
&& CALCULATE (
MIN ( 'Table'[CreatedDate] ),
T,
VALUES ( 'Table'[Opp_DealR] ),
VALUES ( 'Table'[CaseNumber] )
) = 'Table'[CreatedDate],
INT ( 'Table'[CreatedDate] - 'Table'[Case_Comp_date] )
)
)
I am not able to send you the message. Error msg is below.
Sample data @tamerj1
Opp_DealR | CaseNumber | CreatedDate | Case_Comp_date | oldvalue | Newvalue | |
DR3622342 | 2197519 | 3/8/2023 | 2/26/2023 | 02 - Prospect | 05 - Solution Definition and Validation | |
DR3622342 | 2197519 | 5/25/2023 | 2/26/2023 | 05 - Solution Definition and Validation | 06 - Customer Commit | |
DR3622342 | 2197519 | 5/26/2023 | 2/26/2023 | 06 - Customer Commit | Closed - Booked | |
DR3622342 | 2197519 | 5/26/2023 | 2/26/2023 | Closed - Booked | 07 - Execute to Close | |
DR3622342 | 2197519 | 6/1/2023 | 2/26/2023 | 07 - Execute to Close | Closed - Booked | |
DR3630255 | 2248914 | 3/20/2023 | 5/1/2023 | 01 - Pre Call Plan | 02 - Prospect | |
DR3630255 | 2248914 | 3/28/2023 | 5/1/2023 | 02 - Prospect | 03 - Opportunity Qualification | |
DR3630255 | 2248914 | 4/18/2023 | 5/1/2023 | 03 - Opportunity Qualification | 04 - Circle of Influence | |
DR3630255 | 2248914 | 5/18/2023 | 5/1/2023 | 04 - Circle of Influence | 05 - Solution Definition and Validation |
Oh that error will go after a while. However, I won't be able to connect neither today nor tomorrow. I'll be available only on Friday.
DR# ID CaseNumber CreatedDate Case_Comp_date Comp_Created_datediff oldvalue Newvalue
DR3622342 0065Y00001hNJCNQA4 2197519 2/15/2023 2/26/2023 02 - Prospect 05 - Solution Definition and Validation
DR3622342 0065Y00001hNJCNQA4 2197519 1/14/2023 2/26/2023 02 - Prospect 05 - Solution Definition and Validation
DR3622342 0065Y00001hNJCNQA4 2197519 3/8/2023 2/26/2023 10 02 - Prospect 05 - Solution Definition and Validation
DR3622342 0065Y00001hNJCNQA4 2197519 5/25/2023 2/26/2023 05 - Solution Definition and Validation 06 - Customer Commit
DR3622342 0065Y00001hNJCNQA4 2197519 5/26/2023 2/26/2023 06 - Customer Commit Closed - Booked
DR3622342 0065Y00001hNJCNQA4 2197519 5/26/2023 2/26/2023 Closed - Booked 07 - Execute to Close
DR3622342 0065Y00001hNJCNQA4 2197519 6/1/2023 2/26/2023 07 - Execute to Close Closed - Booked
yes, you are correct, it is a calculated measure. Attached is the sample date.
Condition is - if Createddate>Case Comp date, then Createddate-Case Comp date, else Null.
Rest of the rows should show blank values.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
8 | |
8 | |
8 | |
6 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
8 |