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.
First off, apologies for posting such a basic question - I've been working with Power BI for about a week with no real experience in it and I'm having to learn as I go with whatever help I can find on Google!
I've merged a couple of tables together to give me some of the fundamental information I need for a profitability report (see examples in screenshot) and have linked it to master data containing an overall "time worked" value from another sheet. Of course because these aren't unique values (i.e. it's many-many) the merged value ("Total Hours") is duplicating across each applicable line. I've dealt with this before using grouping/index columns but in this case those tricks won't work.
What I need to do therefore is average out the Total Hours column by the count of Staff ID and Period (calculated to be end of month) but I don't know the syntax. I found another solution which suggested using an average over each but that applies the result to every line item equally and doesn't filter down by unique entry.
Please could I get a pointer? In the example attached lines 2 to 4 would show 15.25, lines 5 to 7 would show 20.5, etc.
Solved! Go to Solution.
I was able to create a solution for myself since originally asking. I created a concatenate column in the data table (not in PQE) combining the staff ID and period to create a single vector indicator. Then I created a second column with a count of that filter using COUNTX, FILTER and EARLIER:
I was able to create a solution for myself since originally asking. I created a concatenate column in the data table (not in PQE) combining the staff ID and period to create a single vector indicator. Then I created a second column with a count of that filter using COUNTX, FILTER and EARLIER:
@Anonymous Where does count of staff id come from? And the Period? Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
Thank you @Greg_Deckler . To answer your points:
ALP01 JA July 2021 3.00
ZER04 JA July 2021 7.00
TEL02 JA August 2021 20.00
ALP01 MB May 2021 5.00
ALP01 MB June 2021 5.00
ALP01 MB July 2021 5.00
ALP01 ST June 2021 2.00
ALP01 ST June 2021 3.75
TEL02 ST July 2021 1.50
ZER04 ST July 2021 0.75
ALP01 ST August 2021 8.00
TEL02 ST August 2021 2.00
ZER04 ST August 2021 1.75
ALP01 JA July 2021 3.00 15.00
ZER04 JA July 2021 7.00 15.00
ALP01 JA July 2021 3.00 7.50
ZER04 JA July 2021 7.00 7.50
I did try to find this particular issue in the FAQ you posted but I can't see it. I also can't post the PBIX file as it contains some sensitive data on staff and clients - I'm struggling to explain this as you can see because I'm not yet familiar with the nomenclature, I'm an old hand at Excel and what I could do there doesn't always translate to what I can do here.
@Anonymous Where is Billed coming from? Seems like you could just SUMMARIZE or SUMMARIZECOLUMNS and take the average?
Hi @Greg_Deckler, as I understand it that's a DAX function whereas I'm processing this in Power Query with the intent of getting a table of standardized data I can use in visualisations - should I be doing this in DAX instead then?
The billed value is taken from a static table (linked to a spreadsheet) which is updated by hand at the end of each month.
Hi @Anonymous ,
Has your problem been solved? If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
Hi @Anonymous ,
Please try the following formula:
AverageBilled =
CALCULATE(
MAX('Table'[Billed]) / COUNT('Table'[Staff ID]),
FILTER(
'Table',
'Table'[Staff ID] = EARLIER('Table'[Staff ID]) && 'Table'[Period] = EARLIER('Table'[Period])
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.