cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Calculate allocation percentage based on the days within a range

Hi All,

I want to create a table visualization, with name of each employee and allocation percentage by month (Within the range of start date and end date).

Output table with – Employeename, Month and allocation percentage à ability to slice by month.

Also, if possible, view the allocation by year or YTD

I have three tables in my model –

Dim_date – date columns

Dim employee – Name, country  and first working date,

Fact_project allocation – empname, startdate, end date , allocation perc( value from 0.1 to 1)

I have attached sample data for reference, please suggest.

So as an output -

 empname month allocationPerc Rocky Dec 2022 50% Rocky Jan 2022 100% Rocky Feb 2022 100%

Dec 2022 - 50% Because only 15days are allocated in that month.
And so on ..!!

..

Thank you .

-Martin

Hi - @wdx223_Daniel  . Would really appreciate if you could help me on this..!!

1 ACCEPTED SOLUTION
Community Support

Hi @MartinAa ,

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table.

``````Output =
var _b = CROSSJOIN(VALUES('Table'[empname]),_a)
var _d = SUMMARIZE(_c,'Table'[empname],[Month],"allocationPerc",DIVIDE(COUNTX(FILTER(_c,[empname]=EARLIER('Table'[empname])&&[Month]=EARLIER([Month])&&[FFlag]<>0),[FFlag]),MAXX(FILTER(_a,[Month]=EARLIER([Month])),DAY(EOMONTH([Date],0)))))
return FILTER(_d,[allocationPerc]<>0)
``````

(3) Then the result is as follows.

Best Regards,

Neeko Tang

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

3 REPLIES 3
Community Support

Hi @MartinAa ,

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table.

``````Output =
var _b = CROSSJOIN(VALUES('Table'[empname]),_a)
var _d = SUMMARIZE(_c,'Table'[empname],[Month],"allocationPerc",DIVIDE(COUNTX(FILTER(_c,[empname]=EARLIER('Table'[empname])&&[Month]=EARLIER([Month])&&[FFlag]<>0),[FFlag]),MAXX(FILTER(_a,[Month]=EARLIER([Month])),DAY(EOMONTH([Date],0)))))
return FILTER(_d,[allocationPerc]<>0)
``````

(3) Then the result is as follows.

Best Regards,

Neeko Tang

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

Frequent Visitor

Thank you very much @v-tangjie-msft ..!!

Super User

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors