Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.
Hello Friends,
Please refer .PBIX and excel file saved at path below :-
Required Output -
I am facing a DAX challange where, we have to calculate the difference between consecutive report dates, and then filter "TransScheduleCompletionDate" by that difference.
For example, the difference between 07-28-2024 and 08-25-2024 is 28 days,
Hence, we have to select report date - "07-28-2024" and then filter "TransScheduleCompletionDate" column to select next 28 days starting from 07/29/2024 (Inclusive) - (29 Jul-25 Aug) and then returning count of transactions 2502 against report date
08-25-2024
Thank you,
Happy learning
Solved! Go to Solution.
@PowerRobots99 Now you have column in your table as well as you know how to calculate scheduled trans. It is very easy to develop such matrix.
However, here is your desired output:
Code Version 1:
ScheduledTrans1 =
IF(
HASONEVALUE(Data[ReportDate]),
MAX(Data[ScheduledTrans])
)
Image showing matrix:
Code Version 2:
DistinctScheduledTrans =
IF(
ISINSCOPE('Data'[ReportDate]),
CALCULATE(
MINX(
'Data',
[ScheduledTrans]
)
),
BLANK()
)
Image showing matrix output version 2:
If you don't want to create a calculated column, then try the below code:
DistinctScheduledTrans_V3 =
VAR CurrentReportDate = MAX('Data'[ReportDate])
VAR PreviousDate =
CALCULATE(
MAX('Data'[ReportDate]),
FILTER(
ALL('Data'),
'Data'[ReportDate] < CurrentReportDate
)
)
VAR DateDiff =
DATEDIFF(
PreviousDate,
CurrentReportDate,
DAY
)
VAR TransactionIDCount =
CALCULATE(
COUNT('Data'[Transaction ID]),
FILTER(
ALL('Data'),
'Data'[TransScheduleCompletionDate] >= PreviousDate + 1 &&
'Data'[TransScheduleCompletionDate] <= PreviousDate + DateDiff &&
'Data'[ReportDate] = PreviousDate
)
)
RETURN
IF(
ISBLANK(PreviousDate),
BLANK(),
IF(
HASONEVALUE(Data[ReportDate]),
TransactionIDCount
)
)
Here is the desired output:
Hope this helps!!
Hi @PowerRobots99 Try below code:
For Report Date Difference
For CompletionDate:
Hope this helps!!
If this solved your problem, please accept it as a solution!!
Best Regards,
Shahariar Hafiz
Hi @shafiz_p
Thank you for your reply, appreciate it,
But, please read my question again, we need output in below form -
@PowerRobots99 Try below code to get the desired output. See image below:
You can also create a new table from the above table by using Distinct and SelectColumns Function:
If this solved your problem, please accept it as a solution and a kudos!!
Best Regards,
Shahariar Hafiz
@PowerRobots99 Now you have column in your table as well as you know how to calculate scheduled trans. It is very easy to develop such matrix.
However, here is your desired output:
Code Version 1:
ScheduledTrans1 =
IF(
HASONEVALUE(Data[ReportDate]),
MAX(Data[ScheduledTrans])
)
Image showing matrix:
Code Version 2:
DistinctScheduledTrans =
IF(
ISINSCOPE('Data'[ReportDate]),
CALCULATE(
MINX(
'Data',
[ScheduledTrans]
)
),
BLANK()
)
Image showing matrix output version 2:
If you don't want to create a calculated column, then try the below code:
DistinctScheduledTrans_V3 =
VAR CurrentReportDate = MAX('Data'[ReportDate])
VAR PreviousDate =
CALCULATE(
MAX('Data'[ReportDate]),
FILTER(
ALL('Data'),
'Data'[ReportDate] < CurrentReportDate
)
)
VAR DateDiff =
DATEDIFF(
PreviousDate,
CurrentReportDate,
DAY
)
VAR TransactionIDCount =
CALCULATE(
COUNT('Data'[Transaction ID]),
FILTER(
ALL('Data'),
'Data'[TransScheduleCompletionDate] >= PreviousDate + 1 &&
'Data'[TransScheduleCompletionDate] <= PreviousDate + DateDiff &&
'Data'[ReportDate] = PreviousDate
)
)
RETURN
IF(
ISBLANK(PreviousDate),
BLANK(),
IF(
HASONEVALUE(Data[ReportDate]),
TransactionIDCount
)
)
Here is the desired output:
Hope this helps!!
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
72 | |
71 | |
69 | |
42 | |
42 |
User | Count |
---|---|
47 | |
41 | |
28 | |
27 | |
26 |