Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I wonder if some of you can help me with the following challenge.
Part of my table looks like the one below (current). I have a start date of a timecard, which is allways Monday. So for Mondays I have an actual date, but not for the the other days of the week. This means it is very hard to make a report over a certain period, lets say a month. I would like the table to look like the second table below (need).
Untill now I have solved it with some coding in Access and some stacked queries and build the visuals in QlikView, but I want to get rid of Access in this particular case and move to Power BI.
Transposing seems not to be the solution, because I need timecards-ID's to be duplicated, not transposed. Only the week days need to be transposed. I also need to generate the timestamps for the days of the week, not being Monday.
The most favourable way to do this would be at the source data, but that is not going to happen.
Next stop would be in the Power BI query, but for now, I don't have a clue how to attack this problem.
Any help, solutions or hints, not necessarily for a solution on query level, will bring you great karma and my greatest thanks 🙂
Bye,
Rudi
Current
timecard start date monday tuesday wednesday thursday friday saturday sunday
123456 1-10-2017 3 4 1 0 5 1 0
123457 1-10-2017 2 3 2 4 1 0 0
Need
timecard actual date day hours
123456 1-10-2017 monday 3
123456 2-10-2017 tuesday 4
123456 3-10-2017 wednesday 1
123456 4-10-2017 thursday 0
123456 5-10-2017 friday 5
123456 6-10-2017 saturday 1
123456 7-10-2017 sunday 0
123457 1-10-2017 monday 2
123457 2-10-2017 tuesday 3
123457 3-10-2017 wednesday 3
123457 4-10-2017 thursday 4
123457 5-10-2017 friday 1
123457 6-10-2017 saturday 0
123457 7-10-2017 sunday 0
.
.
.
Solved! Go to Solution.
Hi,
To do this in PowerQuery(Query Editor)
Hi,
To do this in PowerQuery(Query Editor)
Hi MarkS,
Spot on! A really nice and clean solution to my problem. The one I thought of myself was much more complicated (7 queries, a query for each day).
It worked perfectly.
Thanks for you great help.
Rudi
Agreed wih @MarkS, unpivot feature will do it. Let us know if it worked out or need further help to unpivot it?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
besides Phil's approach - I was thinking there is an UnPivot feature in the query editor. I myself haven't needed to use it - so am not 100% sure but the idea is in the back of my mind that there is...... hope I'm not sending you on a wild goose chase but it would only take a minute to review that....
This must be close... Create this as a new table
Need =
SELECTCOLUMNS (
FILTER (
CROSSJOIN ( 'Current', Dates ),
'Dates'[Date] >= 'Current'[start date]
&& 'Dates'[Date]
< 'Current'[start date] + 7
),
"Time Card", 'Current'[timecard],
"Acutal Date", 'Dates'[Date],
"Day", FORMAT ( 'Dates'[Date], "DDD" ),
"Hours", SWITCH (
FORMAT ( 'Dates'[Date], "DDD" ),
"Mon", 'Current'[Monday],
"Tue", 'Current'[Tuesday],
"Wed", 'Current'[Wednesday],
"Thu", 'Current'[Thursday],
"Fri", 'Current'[Friday],
"Sat", 'Current'[Saturday],
"Sun", 'Current'[Sunday],
-1
)
)
Thanks Phil.
MarkS came up with an even better solution, but thanks for thinking with me.
Rudi
User | Count |
---|---|
100 | |
87 | |
81 | |
76 | |
71 |
User | Count |
---|---|
113 | |
104 | |
100 | |
73 | |
65 |