I am trying to create a column in Power BI to group the rows of that data on.
I want the column to output text based on a comparison of dates.
Example:
projected = if(staticdate1 > dynamicdate, "XX", if(staticdate1 < dynamicdate && staticdate2 > dynamicdate, "YY", .... )
The dynamicdate presumably would be a filter or slicer the user could click a date on, thus changing the output of the column, and the totals per output would also change.
Is this possible? I've tried SELECTEDVALUE() but that didn't work. I tried creating a "what-if" parameter and adding that to a static date, but that didn't change anything when I changed the parameter.
That’s not possible since calculated columns are static and don’t recalculate on filter changes. This works with measures only.
Related
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!
I need to filter the table so it can look like the image.
I need to filter out the table so that if (leave*3)<remain only those outputs should be shown.
I tried to use a calculated column and used dax:
remain_find =
var remaining = Voting[Remain]
return IF(Voting[3 x leave] < remaining, remaining)
But it shows blank where the condition fails. I need to do this without any blanks.
Add your measure to the filters of the Visual.
Set the filter on the measure to exclude blanks:
I have a table with a value ReportDate, which is in the format '03/01/2020'. I want to create a slicer in my Power BI report that displays only the format '03/2020' and the user can then select the value of the month and year to display, and it will display the data for that month (regardless of the day value). How would one go about doing this? I know technically I can add a new column in the database table, but unfortunately I do not have access to changes in the database and as such, would like a Power BI solution.
In the Power Query Editor create a new column with formula
Date.ToText([Date], "MM") & "/" & Date.ToText([Date], "yyyy")
Change [Date] to whatever your date column is called. Date.ToText converts a date time to text, which is then concatenated. You can then filter on that column. For issues like this it is best to have some sort of calendar table.
You can create a new column in using query editor in power bi:
mon_year = left(<column_name>, 3) & Right(<column_name>, 4)
Note: Make sure your are connected to dataset in import mode because in live connection you will not be able to create New Column in 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)
I am new to Power bi but i want to use Slicer(user selection) while filter data with comparison by 'Greater Than' instead of equal to.
I have data of devices with LastUpdated date column. and slicer with few list of dates for 15 days gap (calendar would be better but as it is not available yet sticking with dates list)
When user select a date in Slicer i want to filter the data whose Lastupdated Date is greater than equal to selected date. How to achieve this? tried columns,measures..
Any help is appreciated.
I think you can create a measure that links the Date list table and the Device table, even if there is no relationship between them. However the measure must be present in your visualization otherwise the slicer will not affect it.
I've created a measure that calculates the maximum date for those rows which last update date is greater or equal than the slicer selection.
CalculatedLastUpdate =
CALCULATE (
MAX ( DeviceTable[LastUpdate] ),
FILTER (
DeviceTable,
DeviceTable[LastUpdate] >= MINX ( DateList, DateList[Date] )
)
)
DateList - a table containing a column [Date] with you date range.
DeviceTable - a table containing device data.
Now you can delete LastUpdate column from your visualization in order to avoid two columns with the same data.
Let me know if it helps.
I don't know about earlier , but now you can modify the date slicer to do as "after" the given date (you can do so by clicking on the icons present in the rightmost side of the slicer visual itself , wher you can select mode of slicer as between , after ,list , dropdown etc.)...which I believe means that you get all data for dates greater than the selected dates for the given column used in slicer which in your case will be LastUpdate.