Forum Discussion
Fill in not existing values
- 7 years ago
Hi AlB ,
thank you for your reply. I took a look into the thread and luckily it pointed me to a possible solution, although not with DAX.
let Source = Tasks, #"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[TaskName]), "TaskName", "Person"), #"Replaced Value" = Table.TransformColumns(#"Pivoted Column",{},(x) => Replacer.ReplaceValue(x,null,"not scheduled")), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"TaskDate"}, "Task", "Person"), #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Columns",{{"Person", type text}, {"TaskDate", type date}}) in #"Changed Type"Source:
First I pivot on the taskName column so that all the task rows get pivoted into columns. As value I take person and as aggregate function 'Don't aggregate'. This creates nulls where no task is scheduled.
Next I replace all nulls with my custom text (eg 'not scheduled') with
Table.TransformColumns(#"Pivoted Column",{},(x) => Replacer.ReplaceValue(x,null,"not scheduled"))Then I unpivot TaskA and TaskB so that I get my Task and Person columns back. but this time with my added values.
This creates my desired output, unfortunately not with dax, but at least I did not have to enter the values in the database.
Result:
hmmm. I think it won't be that simple. I'd forgotten I came across this issue some time back. Check this out:
https://community.powerbi.com/t5/Desktop/Force-displaying-of-measure/td-p/659059
Hi AlB ,
thank you for your reply. I took a look into the thread and luckily it pointed me to a possible solution, although not with DAX.
let
Source = Tasks,
#"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[TaskName]), "TaskName", "Person"),
#"Replaced Value" = Table.TransformColumns(#"Pivoted Column",{},(x) => Replacer.ReplaceValue(x,null,"not scheduled")),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"TaskDate"}, "Task", "Person"),
#"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Columns",{{"Person", type text}, {"TaskDate", type date}})
in
#"Changed Type"Source:
First I pivot on the taskName column so that all the task rows get pivoted into columns. As value I take person and as aggregate function 'Don't aggregate'. This creates nulls where no task is scheduled.
Next I replace all nulls with my custom text (eg 'not scheduled') with
Table.TransformColumns(#"Pivoted Column",{},(x) => Replacer.ReplaceValue(x,null,"not scheduled"))Then I unpivot TaskA and TaskB so that I get my Task and Person columns back. but this time with my added values.
This creates my desired output, unfortunately not with dax, but at least I did not have to enter the values in the database.
Result: