Hello Stackoverflow community,
I am a novice in Power BI DAX syntax writing and am desperate for assistance on a problem at work.
Here's the short of it: I have one table which has the RAW data being pulled from Smartsheet. I have a second table I made for a weighted calculation which I cannot figure out how to write.
In this other table I made, I'll call it WEIGHTEDTABLE, I have a [Brand] column with text I typed in when I made the table (Brand1, Brand2, etc). Then I have two columns which I would like to populate with a formula. These two other columns are for Item1 and Item2.
The reason behind this is I can have a graph with just counts of Item1 and Item2 for each brand, but that is not fair/accurate because some brands have more of an item than another (which is why I want to created a WEIGHTED table).
The graph I want to create would have the Brands on the Axis, and the values would be the COUNT of Item1 and Item2 / the appropriate number that I will enter (let's just say it's 25 for Item1 and 10 for Item2).
So ideally, it would be a COUNTIF or IF - if [Brand] from the RAW table = [Brand] from the table I entered, then there would be a COUNT of Item1 from the RAW table divided ( / ) by a 25 or 10.
That's it! Perhaps there is a much easier way to do this. Anything helps and I really appreciate the time and effort that goes into responses!
Related
I am trying to find the sum for defective effort but I need it to only sum distinct WorkItemId where Links.TargetWorkItem.WorkItemId is not blank
Measures I currently have:
Defective Effort = CALCULATE(SUM('Work items with direct links'[Effort]),NOT(ISBLANK('Work items with direct links'[Links.TargetWorkItem.WorkItemId])))
For the Sum in the table below (and in the chart) I am wanting the total to be 31 not 35, The Effort for ID 10829 is Getting counted twice
The problem I was having turned out to be the relationship between two tables. Created a table with only one entry for each sprint # then tied all the tables back to that table with a 1:many instead of many:many. This resolved the problem.
Thanks everyone for your help.
I'll start by saying that I'm fairly new to Power BI and am finding my way around, but really am struggling with the concept of lists in a column. I'll explain where I have got in a made up but real world example - sorry if it is rather long winded.
So for my example I have orders in a restaurant, as per the following table:
ID Person Order Alcohol
1 Bob Pizza,fries,beer Yes
2 Fred Pizza,salad,dressing,wine Yes
3 Pete Lasagne,fries,cola No
4 Dave Pizza,fries,cola No
5 Bob Sundae No
I would like to be able to show on a report
A data card showing the count of orders
A list of all of the orders showing all the columns as they are above
A bar chart showing the number of times each item was ordered
A doughnut showing orders which included alcohol
I'd also like to be able to filter across those visualisations, i.e. clicking a row in a bar chart or a portion of the doughnut filters the other visualisations. So, I could for example see which orders included alcohol, or how many people ordered fries and alcohol.
This is where I am becoming stuck.
In order to get the count of the each of the items ordered, I have duplicated the Order column, calling it OrderItem, and then split OrderItem on the comma delimiter, creating new rows. Doing this gives 14 rows, but allows me to
Show the data card (counting distinct ID)
Show the list of orders (Table visualisation showing the columns other than OrderItem)
Show a bar chart of all of the items and the number of times they were ordered
Show a doughnut of alcohol (BUT it is showing 14 items because it is counting rows in the table rather than the overall orders)
Do the filtering across visuals
So I'd like to know how I can get the count of alcohol to reflect the distinct orders rather than the total number of rows.
One approach I tried was to create a duplicate table in PowerQuery, and split that duplicate into rows for each Order Item. That works to a fashion in that I can use the original table for the alcohol doughnut and the table with a row for each item for the counts.
The downside with that approach is that if I click the "fries" row in the bar chart, it doesn't then filter the alcohol doughnut to show which orders with fries had alcohol.
Any advice on how to get the correct count in the doughut AND the filtering would be very much appreciated!
Separate order by Comma (Already completed)
Unpivot the data. First select the relevant order columns, then click unpivot columns at top.
Now each order has a value to it, so you can begin to specifically start counting each specific order item. These values will be unique.
As you mentioned, the issue now is alcohol, ID, and person are duplicated. This is where measures are important. So for alcohol, you create a measure.
Measure = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER('Table','Table'[Alcohol] = "Yes"))
To get the no values, simply do the same measure with "No"
Hi I have two tables one has a large number of orders with a column for date. The second table has one column labeled month and another with hours making for 12 rows in total. I want to make a new column by dividing the count of orders per month by the hours of that month from the second table.
In excel i'd simply countif orders that are in January from the first table and divide by the hours in January from the second.
I'm having trouble figuring out the best way to make this new table with calculated values from the existing tables.
Thanks for your time.
Below is a picture of table 2. The first table is a standard dataframe with thousands of rows.
Two options.
You can use the "Append Query" and create a new table that is combining all of your data.
You can also use CALCULATE(SUM(table[field]), filter(table, table[field] = table[monthfield]) /SUM(table[field])
If you could give an example of what you have, I could definitely show you how to accomplish this.
Here is a link to the solution file. One by merging data, and one by using CALCULATE(SUM(),FILTER())
https://drive.google.com/file/d/1yxpv62Dnv8LSNW_mxibPfL0aCMrepoCU/view?usp=sharing
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'm trying to create a column that has a total of values between 3 columns from 3 tables. How would I go about doing this?
The 2 tables are tables of values that share an id, and they are both linked to a table of account by Id. The goal is to add up 3 columns, and place it into a table grouped by the Id.
I've attempted summing them, trying to use the USERELATIONSHIP function, and creating a relationship between them. It seems to give very inaccurate results, as if it's summing all of the totals together, and passing them to each Id. That, or it won't let me use the column, as if it never existed.
EDIT: General Idea of what I'm trying to do (Lines should be pointing to Account's Id column, but I messed up the lines)
EDIT 2: I also forgot to illustrate or mention. There are more columns with information in each table that can't be summarized for each account preventing me from just merging the table together.
Make sure your data model looks like this (change names as you please, but the structure must be the same):
In dimensional modeling, your table "Account" is a Dimension, and both fee tables are Fact tables. The operation of combining data from multiple fact tables that share the same dimension is called "drill-across", and it's a standard functionality of Power BI.
To combine fees from these tables, you just need to use measures, not columns. This article explains the difference:
Calculated Columns and Measures in DAX
First, create 2 measures for the fees:
Fee1 Amount = SUM(Fee_1[Amount])
Fee2 Amount = SUM(Fee_2[Amount])
Then, create a third measure to combine them:
Total Fee Amount = [Fee1 Amount] + [Fee2 Amount]
Create matrix visual, and place Account_ID from the Account table on the rows. Then drop all these measures into the matrix values area, like this:
Result:
Of course, you don't have to have all these measure in the matrix, I just showed them for your convenience, to validate the results. If you remove them, the last measure still works: