Reputation: 139
I having an requirement from business users and need your help.
From the screenshot, we have BatchNo column, for example the BatchNo HL18002040, business users want to merge Loading Dates into 1 row if they have same BatchNo and then summerizing NetWeight Shipped togother as the Expecting result. I have tried a lot with DAX language but cannot solve the issue.
Please help.
Thank you in advance.
Upvotes: 1
Views: 1104
Reputation: 4015
Depending on your requirements you can do one of three things:
Loading Date
column altogether as suggested by PeterLoading Date
column (e.g. "Earliest" or "Latest" date, again depending on what makes sense for your use case)Option 1 and 2 should need little explanation, but for option 3 the measure could look like this (EDIT: Updated with more information about your data model):
Loading Dates =
IF (
ISINSCOPE ( 'Fact_Shipping'[BatchNo] ) , // Blanks measure in total row
CONCATENATEX (
Fact_Shipping ,
-- Format function may not be needed depending on your data model settings and requirements
FORMAT (
RELATED ( DimDate[Date] ) , "yyyy-MM-dd"
) ,
UNICHAR(10) // Newline character
)
)
You can also use this measure that uses the Fact_Shipping[DateSK]
column directly, use the performance analyzer in Power BI or benchmarking tool in DAX Studio to see which of these perform better for your use case:
Loading Dates 2 =
IF (
ISINSCOPE ( 'Fact_Shipping'[BatchNo] ) , // Blanks measure in total row
CONCATENATEX (
VALUES ( Fact_Shipping[DateSK] ) ,
LEFT([DateSK], 4) & "-" & MID([DateSK], 5, 2) & "-" & RIGHT([DateSK], 2) ,
UNICHAR(10) // Newline character
)
)
Which produces the following result:
Note that your NetWeight Shipped
column should be summed using a dedicated measure or using the implicit column measure function in Power BI. I recommend adding an explicit measure to do this:
Total NetWeight Shipped = SUM ( 'Table'[NetWeight Shipped] )
If you are not using an aggregation on the weight column, the visualization will show multiple rows per BatchNo
. In the picture above, an implicit column measure is used to summarize the NetWeight Shipped
column.
Upvotes: 1
Reputation: 12375
Use SUM(NetWeight Shipped) but remove [Loading Date] from the visual, so that it stops filtering the measure, thereby hindering the aggregation.
Upvotes: 0