I'm new to PBI Desktop & StackOverflow in general. If anyone can help me out with this situation, much appreciated.
I created this matrix table where it displays the count of male/female students in a student division (I just made up these numbers). I created a measure called 'Percentage of males' that calculates the number of male students and divide it by the total number of students in each division.
The calculation wasn't, the hard part, but the issue is when I place the measure in the values field. Instead of just wanting to show it for totals only, it appears under the female & male subcategories as well (refer to image). Does anyone know if there's a way to modify the measure so that it only affects the total?
I tried looking at some videos, but couldn't really find one for this situation.
Proportion of Males = DIVIDE(
COUNTX(
FILTER(sheet2, Sheet[M/F]="M"), Sheet2[M/F], COUNTA(Sheet2[M/F]), 0)
Related
I'm new to DAX. Looking for your expertise. Looked all over the web but couldn't find a proper solution.
I have a matrix that shows several factories and it's inventories, the rows being factory and SKU. I've created a measure that's the difference between two other measures. The overall idea is: I have a inventory quantity and an orders volume. I defined a "balance" measure that's inventory - sales. That is, what is still left for sale.
Normally it works fine, but when I have a negative value in balance, things get messed up. The subtotal in the factory row sums all the numbers, including negatives, giving me a balance subtotal that is smaller than it's supposed to be. I can't count the negatives. So I've tried to solve this by defining the measure as
Balance = IF([Inventory]>[Sales],[Inventory] - [Sales],BLANK())
Now this works fine visually to display only the positive values in balance, but still sums up the negatives in the factory subtotal.
How can I make this measure to only show and sum up the positives?
I appreciate your help.
P.S.: the inventory and sales measures are basically SUM's of different tables for simplicity and understanding by my part
Matrix with measures. The columns are "Estoque" as inventory, "Embarque programado total" as sales and "Saldo Disp. Venda" as the balance
Create a measure with the below code.
Balance = CALCULATE(SUM([Inventory]) - SUM([Sales]), FILTER(Table1, [Inventory]>[Sales]))
As it turns out, I was able to find a solution through trial and error. I changed my measure to (FatoEstoque is the table that contains the inventory numbers):
Balance= CALCULATE([Inventory]-[Sales],FILTER(FatoEstoque,[Inventory]>[Sales]))
Although I'm not even sure why it works (lol), it works! So I'm not complaining. This measure only sums up the positive values, showing the correct subtotal as I needed.
Filtering the Inventory table to values where [Inventory]>[Sales] works, but adding another filter with the Sales table and the same condition don't.
Here is an image comparing the results. The new measure is called SaldVender2
To preface this, I'm fairly experienced in Excel and VBA but new to PowerBI and more than a bit confused.
I have a flat table with a [creationdate]-, [Prio] (Priority (1,2,3)) and a calculated [Days Open] column, among many irrelevant others. I need to create a chart that displays the average days a case was open by priority of the case.
To display the average "days required" per (opening-) month for the past 18 months, I created the following measure:
Prio 1 = CALCULATE(AVERAGE('SourceName'[Days Open]),'SourceName'[Prio]=1)
Then I used that as a value, and used the [creationdate] as the x-axis. (Later I changed the x-axis to a new date table linked to [creationdate] without it making a difference.) To display this as monthly averages, I used the hierarchy limited to years and months, and went down one level in the chart.
Something seemed off so I checked first in Excel, then in the data source in PowerBI and yep: The averages in the PowerBI chart are complete bullshit.
Where did I go wrong? I assume it has something to do with the date hierarchy... So I created a date table as recommended (which....why?!) and linked it. That didn't make a difference.
Meanwhile in the data panel if I filter by the date column and calculate the average with the filtered selection of numbers externally, everything works as expected, so its not like there's a date formatting issue.
Do I have to create a calculated column with something akin to
DATE(YEAR([DateColumn]),MONTH([DateColumn]),1)
, then use that as the x-axis without the hierarchy, and hope nobody cares about the day in the label? Or is there something wrong with the measure used? I'm completely lost.
I am looking to calculate an annual percentage change, from today of a number of stock market indices. The data is a flat structure un-pivoted about the date column.
I am using a calendar with daily values extending to the end of the current year. My current code:
Ann pch =
VAR
__EarliestValue = CALCULATE(SUM('Equity Markets (2)'[Value]),
SAMEPERIODLASTYEAR( 'Calendar'[Date]))
VAR __LastDateValue = SUM('Equity Markets (2)'[Value])
RETURN
CALCULATE(
DIVIDE(__LastDateValue,__EarliestValue)-1)
returns answers which are clearly incorrect.
I am very much a DAX/PBI novice.
DATA:
I also have a Calendar table:
I think that the metric is actually correct, what makes you believe it is not? Can you share your output?
What you need to do now is to put it into a context, ie put 'Calendar[Date]' into the desired visual (table for instance). If you don't do so, you'll calculate the total amount of value divided by the total amount of value for dates prior to one year, which might return quite a weird number. If you do so, on the other hand, you should get your YoY comparison.
Something to note - there are also quick measures:
Check them out, as one of them is actually YoY total, which you might want to try.
I am pretty new to Power BI, but I'm learning alot fast. I do have one challenge at this point that has me stumped and I'm really not finding anything online that relates very closely.
I have created a basic matrix visualization that gives me sales totals by UPC code. The UPC code is in the Rows and the sales total is a Values column. I added a second instance of the sales as another Value to be calculated as a percent of the column total.
After sorting, I get a nice pivot table style look at the top selling UPC codes.
For the life of me, I can't figure out how to add a calculated column that will give me a cumulative total of the percent so I can do a Top 80 (80/20) analysis. I'm hoping someone can point me in the right direction.
To be completely clear, I want a column to the right of the '%CT Sold Total' column that gives me '14.40%' on the first row, '27.46%' (14.40% + 13.06%) on the second row, '36.41%' (27.46% + 8.95%), and so on.
Thanks in advance!
Finally wrapped my head around this (powerbi.tips/2016/10/pareto-charting) and it is exactly what I was trying to do.
New to DAX.
I have a rather (from my point of view) complicated tables relationship model :
Model
It's a knowledge database in my company.
There are many "compétences" for each employee in table DONNEES. These "compétences" are categorized in the LMC table which is a bridge table between COMP & METIERS defining the "compétences" needed for a "métier".
One "competence" can be in multiple "métiers"
In table "DONNEES" I have all employees, plus standards profils for each "métier". This table defines the level (1 to 5) for each "competences".
My matrix in Power Bi works like a charm. I can sum all "competences level" for each métiers.
I've added a measure, which normalizes this sum over the sum gotten for each standard profil (this sum is "hard coded" in METIERS, not calulated)
Grade = CALCULATE(SUM(DONNEES[Niveau]); LMC)/CALCULATE(SUM(METIERS[Niveau_type]);LMC)*5
And it works (even if the "total" columnn isn't correct)
//EDIT//
With the following modifications, it works :
Grade = CALCULATE(SUM(DONNEES[Niveau]); LMC,DONNEES,METIERS)/CALCULATE(SUM(METIERS[Niveau_type]);LMC,DONNEES,METIERS)*5
(I've added all tables from my many to many relationship)
The grand total column is now ok.
//EDIT//
Now, I want to compute a the number of employee that fulffil a specific grade for each métier.
I've thought to create a binary measure that checks that :
gradefulfilled= IF(DONNEES[Grade]>4,5;1;0)
An then use the total row to have the number of employees in the company able to do that "métier"
It doesn't work. The total sticks to zero, even if the gradefulfilled binary is correct for everyone.
//EDIT//
The total does'nt stick to zero, it can be 1 if there's one employee OK, but sticks to 1 if more than one employee.
//EDIT//
You can propose either a totally different way to compute what I want (number of employees able to do a "métier" or explain to me where I made a mistake in my computations.
Hurray !
My bad. Problem seems solved.
The problem seems related to the way grand total is calculated in pivot table (the sum of the measure calulated for each line, not on the sum of each measure in the matrix)
So I've used a sumx to get a proper sum :
Nbgradefulfilled = sumX(NOMS;DONNEES[gradefulfilled])