Forum Discussion
How create additional table based on specific status
- 11 months ago
Hi Boopep,
I have reproduced your scenario in Power BI Desktop. You can achieve this by creating a new table that filters based on duplicates and status.
Here’s one way using DAX:
NewTable = VAR WithCounts = ADDCOLUMNS ( Claims, "CountPerSeries", CALCULATE ( COUNTROWS ( Claims ), ALLEXCEPT ( Claims, Claims[ClaimSeriesNumber] ) ) ) RETURN FILTER ( WithCounts, [CountPerSeries] = 1 || ( [CountPerSeries] > 1 && Claims[Status] = "Refiled" ) )This logic will:
- Keep all unique ClaimSeriesNumber rows.
- For duplicates, only include those where the Status = "Refiled".
I tested this with sample data and got the expected result:
For your reference, I am attaching .pbix file and thank you, Ilgar_Zarbali , MohamedFowzan1 & Shahid12523 for sharing your valuable insights.
Best regards,
Ganesh Singamshetty.
You want to create another table in Power BI that:
- Starts from your claims table.
- Keeps all ClaimSeriesNumber values.
- BUT: if a ClaimSeriesNumber has duplicates, then keep only those rows where Status = "Refiled".
In Power BI you have two options:
- Power Query (M) → for a physical table in the model.
- DAX (calculated table) → also a physical table, but created with DAX formulas.
A. Power Query (M)
- In Power BI Desktop → Transform Data.
- Duplicate your claims table.
- Group by ClaimSeriesNumber (choose All Rows).
- Add a custom column logic:
* If the grouped table has only one row → expand all rows (keep it).
If the grouped table has >1 rows → filter it down to Status = "Refiled".
- Expand back to a flat table.
M code pattern:
let
Source = Claims,
Grouped = Table.Group(Source, {"ClaimSeriesNumber"},
{{"AllRows", each _, type table [ClaimSeriesNumber=..., Status=...]}}),
AddFiltered = Table.AddColumn(Grouped, "Filtered", each
if Table.RowCount([AllRows]) = 1
then [AllRows]
else Table.SelectRows([AllRows], each [Status] = "Refiled")
),
RemoveOthers = Table.RemoveColumns(AddFiltered,{"AllRows"}),
Expanded = Table.ExpandTableColumn(RemoveOthers,"Filtered",{"ClaimSeriesNumber","Status"})
in
Expanded
That gives you exactly the table you want.
B. DAX (Calculated Table)
If you prefer DAX, create a new table:
FilteredClaims =
VAR WithCounts =
ADDCOLUMNS (
Claims,
"SeriesCount", CALCULATE ( COUNTROWS ( Claims ), ALLEXCEPT ( Claims, Claims[ClaimSeriesNumber] ) )
)
RETURN
FILTER (
WithCounts,
-- Keep all singletons
[SeriesCount] = 1
||
-- If duplicates, keep only Refiled
( [SeriesCount] > 1 && Claims[Status] = "Refiled" )
)
This gives you a new physical table in the model.
Result:
- If a ClaimSeriesNumber appears only once → that row stays regardless of status.
- If it appears multiple times → only the “Refiled” rows remain.
I hope it will help