Forum Discussion
custom column with switch statement
- 8 years ago
Then the Switch statement that you mentioned is working perfect right?
In this case as well, create two columns
Name of Day
= SWITCH(
WEEKDAY(table[Date],2),
1,"Monday",
2,"Tuesday",
3,"Wednesday",
4,"Thursday",
5,"Friday",
6,"Saturday",
7,"Sunday")and
Day of Week = WEEKDAY(table[Date],2)
Then use Sort by column option as suggested before.
anithat thanks for your reply. What you mentioned will fetch day name in text. This is what i expect but this makes sorting difficult.
The above result will only allow us to sort by alphabet which makes visuals weird. I wanted the visual to be ordered beginning from Monday. For this purpose, I used switch statement by manually using numbers at the beginning like "1.Monday".
I did this in a calculated column. Now trying to figure out in a custom column
Thanks,
create two columns
Day of Week which gives numeric value
Name of Day which gives Name
Apply & close
Go to 'Data' or 'Report' tab (on left side )
Go to 'Modelling' tab (on Top)
Choose the column "Name of Day"
Click on 'Sort by Column'
From the dropdown list choose "Day of Week" and that will sort the "Name of Day" by "Day of Week"
- indhu8 years agoHelper III
anithat thanks for your suggestion. The database is very huge and the refresh time now takes about 20-30 mins. I reckon adding one more column will add up the load.
Is there any way I can use the switch statement in power query?
I will test the refresh time for both as well.
- anithat8 years agoResolver II
Then the Switch statement that you mentioned is working perfect right?
In this case as well, create two columns
Name of Day
= SWITCH(
WEEKDAY(table[Date],2),
1,"Monday",
2,"Tuesday",
3,"Wednesday",
4,"Thursday",
5,"Friday",
6,"Saturday",
7,"Sunday")and
Day of Week = WEEKDAY(table[Date],2)
Then use Sort by column option as suggested before.