Hello.
I'm new to Power BI and need help figuring this out.
I have legacies of employees with various licenses. Each legacy can have several licenses in a year.
The number of days is counted by counting the days between Date from and Date To (including the day of the Date To)
When the number of days falls in different months, I need to allocate that number of days to the respective month and be able to visualize per month the number of days per legacy.
Ex: the start date is 06/01/2021 and the end date is 05/03/2022 - the total number of days is 337.
I need to see per month the respective number of days of that license.
Thanks a lot!
Solved! Go to Solution.
Hi @Syndicate_Admin ,
I use this table for testing.
You need a date table with all consecutive dates and a column as the X-axis of the year month column.
CALENDAR = CALENDAR(MIN('Table'[Fecha desde]),MAX('Table'[Fecha hasta]))
Month Year = FORMAT('CALENDAR'[Date],"YYYYMM")
No relationship needs to be created between the two tables.
Then create a measure.
Number of days by month =
CALCULATE(
COUNTX(
SUMMARIZE(
FILTER(
CROSSJOIN('Table','CALENDAR'),
'CALENDAR'[Date] >= 'Table'[Fecha desde]
&& 'CALENDAR'[Date] <= 'Table'[Fecha hasta]
),
'Table'[Legajo],
'CALENDAR'[Date]
),
'CALENDAR'[Date]
)
)
Select a visual and drag the fields and measure into it.
Attach the pbix file for reference.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi @Syndicate_Admin ,
I use this table for testing.
You need a date table with all consecutive dates and a column as the X-axis of the year month column.
CALENDAR = CALENDAR(MIN('Table'[Fecha desde]),MAX('Table'[Fecha hasta]))
Month Year = FORMAT('CALENDAR'[Date],"YYYYMM")
No relationship needs to be created between the two tables.
Then create a measure.
Number of days by month =
CALCULATE(
COUNTX(
SUMMARIZE(
FILTER(
CROSSJOIN('Table','CALENDAR'),
'CALENDAR'[Date] >= 'Table'[Fecha desde]
&& 'CALENDAR'[Date] <= 'Table'[Fecha hasta]
),
'Table'[Legajo],
'CALENDAR'[Date]
),
'CALENDAR'[Date]
)
)
Select a visual and drag the fields and measure into it.
Attach the pbix file for reference.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!
User | Count |
---|---|
219 | |
66 | |
61 | |
60 | |
57 |
User | Count |
---|---|
251 | |
208 | |
87 | |
77 | |
73 |