I want to see if it is possible to create a conditional formatting on a column name/value on a matrix table in Power BI. I have attached a screenshot of what I'm trying to achieve. The column name would be highlighted based off of today's date.
UPDATED
If it is not possible to highlight the column name, is it possible if all the values are highlighted based off the date on the column value?
Similar to this post, you can define a measure to use in a conditional formatting rule.
Use a measure like
IsToday = IF ( SELECTEDVALUE ( DateTable[Date] ) = TODAY(), 1, 0 )
and write your rule to highlight based on IsToday equals 1.
Related
I have a situation in which I am using Microsoft Power BI. I have a source table (called Couriers), with a range of weights (MinWeight to MaxWeight) for any given combination of Courier and Country, along with the Freight value.
I need to develop a new TABLE (called Couriers_FlattenedData) in Power BI , in which, I get a row for each value between the MinWeight and MaxWeight.
For example, if the minimum weight to maximum weight reads as 0 and 5 for FedEx Australia, I need 5 rows from 1 to 5.
I need these 4 columns in the new Couriers_FlattenedData table - Courier, Country, Weight, Freight. The Weight column is converted to rows based on the range in the source table.
I am trying to derive the new table, in both DAX as well as using the backend Power Query Editor (using M language). I would like to get both ways to develop this new table.
I tried something like this in DAX, but not able to get a solution.
Couriers_FlattenedData = SELECTCOLUMNS (
GENERATE (
'Couriers', GENERATESERIES (
CALCULATE(DISTINCT(Couriers[MinWeight])+1),
CALCULATE(DISTINCT(Couriers[MaxWeight]))
)
),
"Courier", Couriers[Courier],
"Country", Couriers[Country],
"Freight", Couriers[Freight]
)
Can someone correct the above DAX expression, which misses the Weight column ? Or even provide a solution using variables?
And also a step by step solution using the Power Query Editor of Power BI ?
DAX Solution:
Couriers_FlattenedData = SELECTCOLUMNS (
GENERATE (
Couriers,
GENERATESERIES(Couriers[MinWeight] + 1, Couriers[MaxWeight])
),
"Courier", Couriers[Courier],
"Country", Couriers[Country],
"Weight", [Value],
"Freight", Couriers[Freight]
)
Query Editor solution:
Duplicate the Couriers table (in the Query Editor), then go to Advanced Editor of the Query Editor, then paste this:
let
Source = Couriers,
WeightList = Table.CombineColumns(Source,{"MinWeight", "MaxWeight"},each {_{0}+1.._{1}},"Weight"),
ExpandWeightList = Table.ExpandListColumn(WeightList, "Weight"),
ChangedType = Table.TransformColumnTypes(ExpandWeightList,{{"Weight", Int64.Type}})
in
ChangedType
Rename the table as Couriers_FlattenedData
I have a table Like this,
Table1
I want to create a column called as Row Number using DAX and not Query Editor (M).
So the Expected output is,
This can be done in M - Power Query Side.
But, I am looking for a solution using DAX- Calculated Column.
Additional source data
The RANKX function should work fine for this purpose.
Row Number = RANKX ( Table1, Table1[ColA] )
Recommended reading:
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
I have a table with columns 'date from' and 'date to', and visualize them as bars using asTimeline visual.
I want to add a slicer which will work on both of these fields simultaneously. Currently I have two slicers working independently on each of those fields:
This is not really intuitive. Since start and end both define a period in time, if the period is inside the slider selection, it should be included. But slicers work on only one field. So I probably need to perform some DAX magic to create a field based on those two, but I don't know where to begin.
First create an measure to check a row overlaps the your date range:
Date Included =
IF (
FIRSTNONBLANK ( DateTable[Start Date], 1 ) <= MAX ( 'Calendar'[Date] ) &&
FIRSTNONBLANK( DateTable[End Date], 1 ) >= MIN ( 'Calendar'[Date] ),
"Include",
"Exclude"
)
and , add above Measure as a filter on your visualisation, where Date Included is Include
Than you can filter your Calendar table to single value, or range.
Also,only overlapping rows from your fact table will be displayed.
The problem can be solved by using a separate calendar-table and a measure: PowerBI filter- selected Date between Start and End date
Another way to solve this, and keep using the two slicers more intuitively, is described here: https://radacad.com/from-and-to-date-slicers-in-power-bi-filtering-based-on-two-fields. The solution describes how to set the properties of those timeline-slicers so that it makes a bit more sense for the user (set the "Start of employment" slicer as Type - After and the "End of employment" as Type - Before).
I have a measure that retrieves the latest bundle string from a column called Message.
The measure works by getting the first single row from SessionEvents and using MAXX to retrieve the Message from that row.
lastBundle =
VAR SINGLE_ROW = TOPN(1,, FILTER(SessionEvents, SessionEvents[StatusId]=4),
SessionEvents[DateTime],DESC)
return MAXX(SINGLE_ROW, [Message])
I want to use this measure in a calculated column but MAXX is not allowed as a part of a calculated column.
How should i change this calculation to work in a calculated column.
You can use SELECTCOLUMNS instead of MAXX as explained more fully in this related Q&A:
Return top value ordered by another column
lastBundle =
SELECTCOLUMNS (
TOPN (
1,
FILTER ( SessionEvents, SessionEvents[StatusId] = 4 ),
SessionEvents[DateTime], DESC
),
"Message", SessionEvents[Message]
)
But I don't see any reason why MAXX shouldn't work too, except your TOPN function has an extra comma.
Edit: I don't think you can do this at all if you are using a DirectQuery. From Microsoft's documentation:
Limitations in calculated columns: Calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions. [...] Functions that are not supported will not be listed in autocomplete when authoring the DAX for a calculated column, and would result in an error if used.
I'm setting up a Power BI report, and want to include conditional formatting. How do I make it possible the conditional formatting in Power BI? (https://www.dropbox.com/s/jdn23l1lkcdi5c3/excel_kpi_marks.PNG?dl=0)?
I tried to use the DAX queries. But I can't get the unicode of the symbols as shown in the above figure.
OneMonthwizIcon = IF ( 'data'[One Month] > 10, UNICHAR ( 128316 ), UNICHAR ( 128315 ) ) & data[One Month]
I expect the output to be shown with different icons with the following conditions.
- Less than -10 Down arrow
- Between -10 and 10 Rectange
- Greater than 10 Up arrow
https://www.dropbox.com/s/elroau3n5iq5p1p/excel_kpi_with_data.PNG?dl=0
If you create a table using 'enter data' with the first column corresponding to an output result of your if statement and the URL column which is a URL to the KPI image you want displayed. (Your dropbox link will work).
Change the Icon column datatype to Image URL:
Then change your measure to output the corresponding number that matches the symbol you want to see for each condition:
OneMonthwizIcon = IF ( 'data'[One Month] > 10, 1, 2 ) & data[One Month]
Then if you create a relationship between OneMonthwizIcon and the 'Condition' column which will match on the condition number. Then you can use the Icon column in your table or on the page and you will be able to see the image.
We don't need to write a dax query for achieving the conditional formatting. The feature is already included on the PowerBI July 2019 update. So it is no more problem. Thanks.