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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
T_BZH
Frequent Visitor

Span period by year and month to display on column chart

Hi,

 

This is my very fisrt post, so be indulgent 🙂

I am working on a very basic problem since days now, so I would appreciate to get the community input on this :

The main goal is to fill a column chart, by year and month based on a very simple data.

I have a table with StartDate_1, EndDate_1, StartDate_2, EndDate_2

These dates can span over several months, even years

I need to get the cumulative amount of days on each period

Example for the first two rows (Year-Month-Day) :

StartEndSep-23Aug-23Jul-23Jun-23May-23Apr-23Mar-23
2023-07-112023-09-0873120    
2023-02-282023-07-03  330313031
 Total7312330313031




Then we have to add the amount of days for the second set of Start and End Dates

Finaly, its getting worst here, as I am not even able to reproduce this logical in Power BI, I have to make this as a running total on a 12 months period!

Could you please advise?

Thanks!

1 ACCEPTED SOLUTION
T_BZH
Frequent Visitor

Hi, 

Here is the solution I found :

- Create a Date table based on the max and min values from the entire periods.

- Create a new table using the CROSSJOIN function filtering dates when within the period only (this adds a new row for each day in a period).

- Create a measure to count the rows, as per the context behavior, this provides the number of days per year, month or whatever you use in your chart or table.

Don't forget to make the right relations between all the tables (including the new Date and Crossjoin tables).

This is it!

Hope this will help some of you as I spent days on it!

View solution in original post

3 REPLIES 3
T_BZH
Frequent Visitor

Hi, 

Here is the solution I found :

- Create a Date table based on the max and min values from the entire periods.

- Create a new table using the CROSSJOIN function filtering dates when within the period only (this adds a new row for each day in a period).

- Create a measure to count the rows, as per the context behavior, this provides the number of days per year, month or whatever you use in your chart or table.

Don't forget to make the right relations between all the tables (including the new Date and Crossjoin tables).

This is it!

Hope this will help some of you as I spent days on it!

amitchandak
Super User
Super User

@T_BZH , check if this between month logic can can help

 

Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM

 

Matrix as Project plan Visual: https://youtu.be/R25QoiyoSVs

Hi,

Thanks for the input, this does not really address my issue, but is a good trick to know.

For now I am working on a join with the date table to generate a table owher I will have one row per day in the period and will have to count the rows for a specific month, year etc ... still working on it ...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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