Forum Discussion
Sum and Order by from table
Hi,
You have just to display a table with your data, the sum will be done automatically, if not, check the format of your column Hours.
Then on the right panel, you can see the filters, do an advanced filter on the hours column : >1000
- mushi10 years agoNew Member
but i need a number not a graph. That works good for graphs but not for giving whole number in a card. e.g. I want whole number in a card
- leonardmurphy10 years ago
Skilled Sharer
If I'm understanding you correctly, you have 2 fields in your field list on the right hand side of Power BI Desktop: Employee and Hours (see screenshot below). When you drag them onto a visualization (such as a table or card) they show each individual row in the underlying Excel sheet instead of summing up.
There are two options, both have the same result:
1. Once you've created your visualization with Employee and Hours underneath in the 'Fields' list of the visualization, there should be a drop down next to Hours. You can click this and instead of 'Do Not Summarize', select 'Sum'. (In the below screenshot I'm using the card visualization)
2. On the data tab (2nd icon on the far left of Power BI Desktop) or by right-clicking in your field list on the far right, create a new measure called Total Hours, defined as Total Hours = SUM(Sheet1[Hours]) (where Sheet1 is the name of your Excel sheet). You can then use this measure instead of hours in your visualizations.
The 2nd method, though a bit of an extra step, is the better practice. My reasoning:
1. As you get more advanced, your measures will go beyond simple sums, counts & averages that the first option is limited to.
2. With the 2nd method you can give it a specific name ("Total Hours" so it's clear that it's a sum and not, say, an average).
3. The 1st method has to be repeated for every visualization you create whereas the measure created in the 2nd method persists in your model forever more and can be selected again and again.
4. If you ever want to change the definition of "Total Hours" (e.g. you want to always exclude managers from the measure or you want to subtract a fixed amount of time for lunch breaks each day), you can change the measure in the future and all the visualizations that use it will automatically reflect the change.
Hope this helps.
- leonardmurphy10 years ago
Skilled Sharer
Assuming I persuaded you on the 2nd method, you can then add a 2nd measure:
Employee Count = DISTINCTCOUNT(Sheet1[Employee])
to get a count of employees.
And to filter to employees with more than 1000 hours, select your Total Hours measure under 'Visual Level Filters' choose 'Is Greater Than' and type in 1000. Since it is a measure, you can only filter the visualization.