Forum Discussion
Add Row if data missing from dataset
- 1 year ago
Hello AsNa_92
As per your requirement you need to create a calculated table cause here you're trying to add a row with the alternative result for category date wise.
So Try the below DAX to create a calculated table;RESULT_TABLE =ADDCOLUMNS(CROSSJOIN(DISTINCT('TABLE1'[Date]),DISTINCT('TABLE1'[Category])),"Value",COALESCE(LOOKUPVALUE('TABLE1'[Value], 'TABLE1'[Date], [Date], 'TABLE1'[Category], [Category]),0))ORThere's another way to get your desired result using M-Queries on transfer data but for that also you need to add another table .ORYou can modify your used database Query.Thanks & Regards...
Hello AsNa_92
It would be better if you share some demo data in order to check the formats and to understand your requirement better.
And as per the mentioned above example;
1 - If you are loading the data using database queries then you can modify the column in the query and load the desired data.
or
2 - You can also create a calculated column with some conditions to get your required result column.
Thanks & Regards...
- AsNa_921 year agoResolver II
Hi BIswajit_Das
Thanks for your reply, if I want to add column with condition how can i apply that?
Since I'm using oracle database table which refresh monthly.
Sample Data:
Date Category Value 2024/09/01 Red 50 2024/09/01 Yellow 40 2024/09/01 Black 5 2024/10/01 Red 90 2024/10/01 Black 30 Output:
Date Category Value 2024/09/01 Red 50 2024/09/01 Yellow 40 2024/09/01 Black 5 2024/10/01 Red 90 2024/10/01 Black 30 2024/10/01 Yellow 0 - BIswajit_Das1 year agoImpactful Individual
Hello AsNa_92
As per your requirement you need to create a calculated table cause here you're trying to add a row with the alternative result for category date wise.
So Try the below DAX to create a calculated table;RESULT_TABLE =ADDCOLUMNS(CROSSJOIN(DISTINCT('TABLE1'[Date]),DISTINCT('TABLE1'[Category])),"Value",COALESCE(LOOKUPVALUE('TABLE1'[Value], 'TABLE1'[Date], [Date], 'TABLE1'[Category], [Category]),0))ORThere's another way to get your desired result using M-Queries on transfer data but for that also you need to add another table .ORYou can modify your used database Query.Thanks & Regards...