Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Hello
I was looking for a way to calculate the same values per month for my model. While searching in various topics, I found this one and it's almost what I was looking for, thank you 🙂
I however have an issue when I create an active relationship between my table 'calendar' et my other 'data table'. The results aren't he ones expected. How can I fix this please ? (I also have other tables in my model, which is why I need an active relationship).
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 @v-cgao-msft !
I followed your guidelines and worked ! Now, if I want to generate a table with the columns, Legajo and the months (jan, feb ... ) with the quantity of days inside, how should I do?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |