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.
Using Report Builder, I created a dataset that contains a date parameter. I need to add an order by to the DAX Query but am unsure of the correct syntax. Example is below. I need to order by 'Task'[ActivityDate] DESC
DEFINE VAR vFromTaskActivityDateHierarchy1 = IF(PATHLENGTH(@FromTaskActivityDateHierarchy) = 1, IF(@FromTaskActivityDateHierarchy <> "", @FromTaskActivityDateHierarchy, BLANK()), IF(PATHITEM(@FromTaskActivityDateHierarchy, 2) <> "", PATHITEM(@FromTaskActivityDateHierarchy, 2), BLANK()))
VAR vFromTaskActivityDateHierarchy1ALL = PATHLENGTH(@FromTaskActivityDateHierarchy) > 1 && PATHITEM(@FromTaskActivityDateHierarchy, 1, 1) < 1
VAR vToTaskActivityDateHierarchy1 = IF(PATHLENGTH(@ToTaskActivityDateHierarchy) = 1, IF(@ToTaskActivityDateHierarchy <> "", @ToTaskActivityDateHierarchy, BLANK()), IF(PATHITEM(@ToTaskActivityDateHierarchy, 2) <> "", PATHITEM(@ToTaskActivityDateHierarchy, 2), BLANK()))
VAR vToTaskActivityDateHierarchy1ALL = PATHLENGTH(@ToTaskActivityDateHierarchy) > 1 && PATHITEM(@ToTaskActivityDateHierarchy, 1, 1) < 1
EVALUATE SUMMARIZECOLUMNS('Task'[WhatId], 'Task'[Status], 'Task'[Description], 'Task'[ActivityDate], FILTER(VALUES('Task'[ActivityDate]), (vFromTaskActivityDateHierarchy1ALL || 'Task'[ActivityDate] >= DATEVALUE(vFromTaskActivityDateHierarchy1) + TIMEVALUE(vFromTaskActivityDateHierarchy1)) && (vToTaskActivityDateHierarchy1ALL || 'Task'[ActivityDate] <= DATEVALUE(vToTaskActivityDateHierarchy1) + TIMEVALUE(vToTaskActivityDateHierarchy1))))
Any assistance is appreciated.
Hi @M_K_T ,
Have you solved the current problem?
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @M_K_T ,
To do this. you can use the clause ORDER BYORDER BY in a DAX query. which allows you to specify the columns to be sorted and the direction of the sort
EVALUATE
SUMMARIZECOLUMNS(
'Task'[WhatId],
'Task'[Status],
'Task'[Description],
'Task'[ActivityDate],
FILTER(
VALUES('Task'[ActivityDate]),
(vFromTaskActivityDateHierarchy1ALL || 'Task'[ActivityDate] >= DATEVALUE(vFromTaskActivityDateHierarchy1) + TIMEVALUE(vFromTaskActivityDateHierarchy1)) &&
(vToTaskActivityDateHierarchy1ALL || 'Task'[ActivityDate] <= DATEVALUE(vToTaskActivityDateHierarchy1) + TIMEVALUE(vToTaskActivityDateHierarchy1))
)
)
ORDER BY 'Task'[ActivityDate] DESC
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
4 | |
4 | |
2 | |
1 | |
1 |
User | Count |
---|---|
7 | |
5 | |
4 | |
3 | |
3 |