Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I am new to Power BI and to DAX, and I am trying to create a measure.
For this question, we need to consider 2 fact tables and a few fields for each:
My goal is to calculate the number of days for each row, between PRC_signoff_complete and Flipped_to_Proposal, only when there is at least one record for that Opportunity in the FactOpportunityRequest table.
I was able to get the number of days by using the following syntax:
SWITCH (
TRUE (),
FactOpportunity[PRC_signoff_complete] > FactOpportunity[Flipped_to_Proposal], DATEDIFF ( FactOpportunity[Flipped_to_Proposal], FactOpportunity[PRC_signoff_complete], DAY ),
FactOpportunity[PRC_signoff_complete] < FactOpportunity[Flipped_to_Proposal], DATEDIFF ( FactOpportunity[PRC_signoff_complete], FactOpportunity[Flipped_to_Proposal], DAY ) * -1
)
Now I am stuck on the filtering, to get the number of days only when there is at least one record for that Opportunity in the FactOpportunityRequest table. If there is no record, it should be blank.
Any idea how to do that?
Solved! Go to Solution.
Hi @Anonymous
Please try
=
IF (
NOT ISEMPTY ( RELATEDTABLE ( FactOpportunityRequest ) ),
VAR SignDate = FactOpportunity[PRC_signoff_complete]
VAR FlipDate = FactOpportunity[Flipped_to_Proposal]
VAR MinDate =
MIN ( SignDate, FlipDate )
VAR MaxDate =
MAX ( SignDate, FlipDate )
VAR NumOfDays =
DATEDIFF ( MinDate, MaxDate, DAY )
RETURN
IF ( SignDate > FlipDate, NumOfDays, - NumOfDays )
)
Hi @Anonymous
Please try
=
IF (
NOT ISEMPTY ( RELATEDTABLE ( FactOpportunityRequest ) ),
VAR SignDate = FactOpportunity[PRC_signoff_complete]
VAR FlipDate = FactOpportunity[Flipped_to_Proposal]
VAR MinDate =
MIN ( SignDate, FlipDate )
VAR MaxDate =
MAX ( SignDate, FlipDate )
VAR NumOfDays =
DATEDIFF ( MinDate, MaxDate, DAY )
RETURN
IF ( SignDate > FlipDate, NumOfDays, - NumOfDays )
)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
23 | |
10 | |
10 | |
9 | |
7 |