I have this table in Power BI, where the visible rows all have the same tracking number, but there are multiple rows due to the sku column.
How can I achieve a result like this where this is shown in just one row, and all skus are listed comma separated:
I have achieved this using pandas, but want to do the same in Power BI. However, I have not been able to find a solution to this issue.
You need to use CONCATENATEX evaluating the list of SKU for that row in your visualization. You measure will need to look something like this:
skus =
CONCATENATEX (
VALUES ( 'Table'[sku] ),
[sku],
","
)
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 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.
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
In Power BI I'm trying to combine and get the unique values of pages in a new table. I need to filter one of the columns, based on a value of another column in that same table. So i want to do something like
FILTER(VALUES('Table1'[URL]), 'Table1'[Correct] = "Yes"
But it's not working, because I can only filter based on calculations, not columns.
The complete line that I have now and is working is:
All pages = FILTER(
DISTINCT(UNION(VALUES('Table1'[URL]),VALUES(Table2[Complete URL]),
VALUES('Table3'[URLs]))), [URL] <> BLANK())
How can I add a filter to one of those tables, based on another column of that table?
You can just replace FILTER with CALCULATETABLE:
CALCULATETABLE(VALUES('Table'[URL]), 'Table'[Correct] = "Yes")
If you need to count the values, just wrap it into COUNTROWS:
Measure = COUNTROWS( CALCULATETABLE(VALUES('Table'[URL]), 'Table'[Correct] = "Yes"))
Within a Power BI report, I want to filter to the latest value in a column of timestamps. It is using a DirectQuery model so I can't use MAX in a calculate column, but I can use it in a measure. I need something along the lines of:
=IF(Query1[TimeStamp]=Calculate(Max(Query1[TimeStamp])),"Latest","")
You can calculate the max for the whole column by removing the filter context:
CALCULATE(MAX(Query1[TimeStamp]), ALL(Query1[TimeStamp]))
The whole measure would look like this:
= IF(MAX(result[Fecha]) = CALCULATE(MAX(result[Fecha]), ALL(result[Fecha])),
"Latest", "")