The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi
I am currently looking to write a DAX measure that looks at the expected hours per day vs recorded hours.
Data structure
Date
Date table
Resource
ID | Name | Role | Start Date | End Date | FTE |
Time Record
ID | Name | Date | Activity | Hours |
Names
Bridging table
Relationships
Date table is linked to Resource on start date and end date with inactive relationships
Date table linked to Time Record on date with active relationship
Time Record linked to Names with active relationship
Resource linked to Names with active relationship
Expected Outcome
1/5/24 | 1/5/24 | 1/5/24 | 2/5/24 | 2/5/24 | 2/5/24 | .... | |
Name | Expected | Actual | Difference | Expected | Actual | Difference | |
Expected hours is 8 hours * FTE but only applies to week days which I wasn't sure how to approach.
This is the measure I've written so far for Expected Hours but it isn't quite working and isn't accounting for week days. Not quite sure where to start with the difference yet either.
Expected Hours =
SUMX(
VALUES('Resource'[Name]),
CALCULATE(
SUMX('Resource',
IF('Resource'[Start Date]<=TODAY() && ISBLANK('Resource'[End Date] && 'Resource'[Start Date]<MAX('Date'[Date]),
'Resource'[FTE]*8,
IF(IF('Resource'[Start Date]<=TODAY() && 'Resource'[End Date]>TODAY() && 'Resource'[Start Date]<MAX('Date'[Date]),
'Resource'[FTE]*8,
0)
)
)
)
)
Any help would be very much appreciated!
Solved! Go to Solution.
@lbendlin , thanks for your concern about this case, I have an addition to make to the content.
Hi @metcala ,
If by weekdays you mean Monday to Friday, you can add the following filter to the formula:
NOT(WEEKDAY(MAX('Table'[Date]),2)) in {6,7}
If by weekdays you mean not only Monday to Friday but also the rest of the holidays, you can first use Enter data to create a table to collect the holiday information and add the following filter to the formula:
NOT(WEEKDAY(MAX('Table'[Date]),2)) in {6,7} && NOT(MAX('Table'[Date])) in SELECTCOLUMNS('Holidays_Table',"date",[Holidays])
If it doesn't meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@lbendlin , thanks for your concern about this case, I have an addition to make to the content.
Hi @metcala ,
If by weekdays you mean Monday to Friday, you can add the following filter to the formula:
NOT(WEEKDAY(MAX('Table'[Date]),2)) in {6,7}
If by weekdays you mean not only Monday to Friday but also the rest of the holidays, you can first use Enter data to create a table to collect the holiday information and add the following filter to the formula:
NOT(WEEKDAY(MAX('Table'[Date]),2)) in {6,7} && NOT(MAX('Table'[Date])) in SELECTCOLUMNS('Holidays_Table',"date",[Holidays])
If it doesn't meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
User | Count |
---|---|
16 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
23 | |
13 | |
13 | |
8 | |
8 |