Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ValeriaBreve
Post Patron
Post Patron

Showing countrows with zero rows for a selected date range

Hello,

I have a table called Date_Table_Action which has a 1->* relationship to table BBP_Actions on the date.

 

I need to display a table that has all the continous dates between the min date on BBP_Actions and the max date on BBP_Actions and the related number of actions (setup is 1 row per action in BBP_Actions).

If there are no actions on that day, it should show zero.

I don't seem to be able to get there... this is my measure:

 

# Count of Actions =
VAR _FilteredDateTable=
CALCULATETABLE(Date_Table_Action,
FILTER(Date_Table_Action,Date_Table_Action[Date]<=MAX(BBP_Actions[ActionCompleteTargetDate])),
FILTER(Date_Table_Action,Date_Table_Action[Date]>=MIN(BBP_Actions[ActionCompleteTargetDate])))
RETURN
CALCULATE(
    COUNT(BBP_Actions[Id]),_FilteredDateTable)

 

In my table, I have all date related fields coming from Date_Table_Action, and the only added field is # Count of Actions.

I only get this in return: either only the dates that have actions (normal), or when I set the "Show Items with no data" to true, then I get the whole range of dates from Date_Table_Actions which is far too wide - it should only be the range as per filter in the measure.

 

Can you please help me understand why this happens and how to modify the  measure to show 1 row per date in the range I wish?

 

Thanks a lot in advance!

Kind regards

Valeria

3 REPLIES 3
v-jiewu-msft
Community Support
Community Support

Hi @ValeriaBreve ,

Based on the description, try using the following DAX formula.

Count of Actions =
VAR _MinDate = MIN(BBP_Actions[ActionCompleteTargetDate])
VAR _MaxDate = MAX(BBP_Actions[ActionCompleteTargetDate])
VAR _DateRange = 
    FILTER(
        Date_Table_Action,
        Date_Table_Action[Date] >= _MinDate &&
        Date_Table_Action[Date] <= _MaxDate
    )
RETURN
SUMX(
    _DateRange,
    CALCULATE(
        COUNT(BBP_Actions[Id]),
        BBP_Actions[ActionCompleteTargetDate] = Date_Table_Action[Date]
    )
)

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

SachinNandanwar
Solution Specialist
Solution Specialist

Can you please post some sample data ?



Regards,
Sachin
Check out my Blog

@SachinNandanwar I don't think I can attach anything unfortunately. For the Date_Table_Actions it would be a simple date table:

ValeriaBreve_0-1728410385761.png

For the BBP_Actions table, here is some sample data from the table. Relationship is 1 --> * from Date_Table_Action[Date] to BBP_Actions[ActionCompleteTargetDate]

IdStatusActionCompleteTargetDate
67Validated12-Sep-24
68New18-Sep-24
69Study Ongoing26-Sep-24
70New12-Sep-24
71New19-Sep-24
72New12-Sep-24
77Completed17-Sep-24
78New17-Oct-24
79New26-Sep-24
80New25-Sep-24
81New26-Sep-24
82New24-Sep-24
83New26-Sep-24
84New26-Sep-24
85New26-Sep-24
86New30-Sep-24
87New30-Sep-24
88New01-Oct-24
89New01-Oct-24
90New10-Oct-24
91New17-Oct-24
92New17-Oct-24
93New 
94New30-Oct-24
98New 
99New 
100New 
101New 
102New 


Thanks!

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors