Calculated column in Power BI based on relationship between 2 tables - powerbi

Hi,
I'm trying to add a calculated column in my MergedTable table that will multiply the Time column by the sum of the indicator in the TeamLeave when the week ending dates and the name dates are the same but I'm not sure how or what functions to use(I've tried a number at this stage).
Could anyone provide me with assistance on this?
Thanks,

This:
'MergedTable'[Time] * CALCULATE(SUM('Team Leave'[Indicator]))
The CALCULATE is necessary to perform a context transition (turning the "current row" of 'MergedTable' into a filter that will propagate to the 'Team Leave' table).

Related

Power BI Slicer on Table 1 to calulate new column on other Table 2

I have a table Numbers and a slicer "num" to filter to a single number.
Then I have a second table Exhibitors with their exhibitorID and size.
Depending on their size I need to rate them. The rating has to depend on the slicer "num":
I need to do this with a calculated column (Expected outcome in GREEN).
Trying something like this did not work:
Calculated Class =
IF(Exhibitor[Space] >= max('Numbers'[num]), "A", "B")
Can someone help me with that calculated column?
Since Calculated Columns are populated at Refreshing the data, Slicer have no impoact on Columns. Only Measures can be affected by Slicer.
So it has to be a complicated Measure for my Visuals.
Thank you.

How do I create a total_sales column in power bi when I have price_per_unit and quantity_ordered

This has got to be the simplest question ever, but after seeing a half a dozen sites I can't figure it out. How do I create a total_sales column in Power BI when I have a price_per_unit column and a quantity_order column?
All I want to do is make a column that says "price_per_unit * quantity_ordered" but all I get are errors about the column not existing, or the SUM calculation wanting a measure, or some such thing.
Thanks
Create a calculated column (not a measure) on the table those two columns are part of and definite is like
Total_Sales = Table1[price_per_unit] * Table1[quantity_ordered]

Create Calculated Table in Power BI based on the earliest date that another criteria is met on

I am trying to create a calculated table in Power BI that will provide one row per person based on the most earliest date that the score column is greater than 9. The initial table is thousands of rows and includes multiple entries per person if more than one score was collected.
Initial table:
Output goal:
Since Supergirl didn't ever have a score > 9, she isn't included in the output. Each person with a score > 9 will have one row with the score that occurred on the first date that the score was > 9 and the Date Completed.
I will then add columns and measures based on this new table. I tried using the summarize function and duplicating the initial table and manipulating it without success and have read many posts and didn't find anything that matched my ask. Please help :)
you could start off with creating an additional calculated column "TenOrMore" where you would simply calculate if Score >= 10 then true else false. Then your next select you can do max or min on the score where column "TenOrMore" is true or select all the values and calculate the next step. I hope this helps.

Subtracting measure value from each row of a table in Microsoft Power BI

I have created two slicers in Power BI for Month and Year. These take the month and year value and in return generate a date.
Eg. Month - May & Year- 2019 generates 01/05/2019 with the help of the a measure formula :
MyFilterDate = DATE(SELECTEDVALUE(ListoY[Year]),SELECTEDVALUE(ListoM[Month],0),"01")
I want to subtract this date with one that is already in a column in the table.
I'm facing an issue when I try to subtract the measure from the existing column by writing DAX.
SUBVALNEW = DATEDIFF([MyFilterDate],Table[Date],DAY)
But when I try to do so, the result is not right. In fact when I try to check the value of [MyFilterDate] in the Data Model, it is not the same value as one calculated in the measure. (It instead looks like it displays the date in Table[Date])
Is there any way to subtract a Dynamically chosen date from a date in a column?
Any help would be appreciated.
I understand what your thinking patern is but power bi works a bit different. Dynamic measures cannot be used with calculated columns. When doing so the value of the measure is not set.
The way to go about this is by creating a Date table:
Date = CALENDAR(MIN(CalendarWeek[Date]);MAX(CalendarWeek[Date]))
Do NOT connect it to the model. From here you can make 2 slicers (based on the Date table). One your set to the month and the other to the year.
Next step is to adjust the MyFilterDate
MyFilterDate = DATE(SELECTEDVALUE('Date'[Date].[Year]);SELECTEDVALUE('Date'[Date].[MonthNo]);"01")
Make SUBVALNEW a measure (cannot be a column because it is dynamic!)
SUBVALNEW = DATEDIFF([MyFilterDate];SELECTEDVALUE(CalendarWeek[Date]) ;DAY)
Ass the Measuer to your visual, see end result below)

Power BI Percentage of Total

I'm trying to get a column to display in a table that will display Users as a percentage of total users. I can get this to work using a calculated column but this does not work with a slicer that allows the user to filter the data. It always calculates against the total of the unfiltered column and not the user filtered column.
I think I need a measure but I can't figure out how to do it.
What I want is :
Users Value / Sum(Users Value Column)
Any Suggestions?
Solved! This was my solution
Measure =
Selectedvalue('dataName'[Users])
/
Calculate(sum([Users]),allselected('DataName'[column]))