Power BI Percentage of Total - powerbi

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]))

Related

How to Filter the Table Values based upon a What-If Parameter Value in Power BI

I have a table and a What if Parameter Slicer as shown in the image below,
What I want to do is make the Slicer interact with the Table, that is, if the Slicer value is greater than any of the Total Sales value of any customer, then that customer should be filtered out from the table.
How do I make sure of this?
I tried to add a Visual Filter on the Total Sales Column and tried to do this, Filter out all the values where Total Sales < Slicer Value, but it also didn't work for me. As it doesn't allow me to add "Slicer Value" attribute in the Visual Filter.
You can download the related Workbook from here: https://drive.google.com/file/d/15x7m3nXdlRgHdPBxOGqrJRVYYX8hEgLp/view?usp=sharing
Why I am doing this using a What-If Parameter and not by simply adding Sales Column as Slicer, is because I want to use the value of this slicer to create additional measures. That is something I can't do with Sales Column
I have a solution for you! Instead of using column , You need to create a measure first using this DAX Code:
Total Sales = CALCULATE(
SUM(transactions[sales_amount]),
transactions[sales_amount] >= SELECTEDVALUE('Sales Amount Filter'[Sales Amount Filter]))
Then If we test it on the same visual:
I hope This is what you want to have in the end!

Calculated column in Power BI based on relationship between 2 tables

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).

DAX query for calculating percentage of sales in Direct Query Mode in Power BI

I have a requirement where i have to summarise the sales data by department and then create a calculated column to show the percentage of how much each department had contributed towards total sales.
Here % should be the calculated column in Direct Query Mode
Since you did not provide much information or what you have already tried, I can't really guess your model, but I hope this gives you a starting point.
Create a new measure:
(replace the table name where needed)
% Sales Sub Category = DIVIDE(
SUM('Sales'[Sales]),
CALCULATE(SUM('Sales'[Sales]), ALL('Sales'[Sub Category])
)

Cumulative Values row wise and with date filter minimum and maximum in DAX(Power BI)

I need help in calculating the cumulative frequencies row wise with minimum date and maximum date selection by users using sliders. Here is the table that I want to generate could you please guide me? I've tried various function and methods but nothing is giving me right answer. Thanks a lot in advance.
Below is the table that I've and I want to generate:
Original Table
Desired Table
To create a running total, create a new measure in your table like this (where Table is the name of your table):
Running Total = CALCULATE(
SUM('Table'[Values]);
FILTER(ALLSELECTED('Table'); 'Table'[Date] <= SELECTEDVALUE('Table'[Date]))
)

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)