Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dansta87
Frequent Visitor

Merge and Collate Data correctly

Hi,

 

I am fairly new to PowerBI and ive been struggling to try and get the correct data, i feel like i am going in the right direction but i need some assistance.

 

I have a Data Query that pulls the following data from an SQL Server:

ITEMDATEUSEDDATERETURNEDUSEDBY
ITEM 12024-01-012024-01-02PERSON1
ITEM 22024-01-032024-01-10PERSON2
ITEM 32022-10-012023-10-01PERSON3

 

I also have a custom CALENDARAUTO table that i use for date selecting via a slicer.

 

I would like to be able to select a day or range of days using the slicer and then show when an item has or hasnt been used over that period, and if a particular item has not been used then i would like it to be shown with no data.
(DATEUSED and DATERETURNED are inclusive).

 

e.g. Output (if i select the date range 2024-01-01 - 2024-01-03)

DATEITEM1ITEM2ITEM3
2024-01-01PERSON 1  
2024-01-02PERSON 1  
2024-01-03 (and so on) PERSON 2 

 

I have tried going down the path of a merge query to merge the calendar table with the data table to get a combined table but it is only showing rows where data exists.

 

I dont know if what i wasnt is even possible, please can someone assist?

 

Thanks

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

to know how to do this watch my video and  pbix File

List.Generate(()=>[DATEUSED],
(x)=> x<=[DATERETURNED],
(x)=> Date.AddDays(x,1))

 https://1drv.ms/v/s!AiUZ0Ws7G26RjHQb92gyVK8szXUS?e=E96kJl

View solution in original post

10 REPLIES 10
dansta87
Frequent Visitor

This is amazing, thank you.

 

I've come across a few potential issues with this method though.

 

There are a total of around 600+ items, meaning that each item needs to be manually added to the table as a column, and new items will also have to be manually added.

- Ive tried merging these into their own table so it can be used for filtering etc, however again each column needs to be typed manually to merge?

 

show me what your table looks like so I can understand what you need

Thank You.

This is essentially the output table i am trying to get:

 

dansta87_0-1705634244168.png

 

With the ability to filter on the item.
But if each ITEM is added as its own column, would i need to aggregate all of these columns into a single column so that i can filter them?

But if each ITEM is added as its own column
why do you have them separately and how is it I don’t understand

Sorry.

 

Following your video.

Pivoting on the ITEM column adds each ITEM as its own column into the table.

try this

 

this is so you can filter by date

 

Thank You.

Using both your solutions i've managed to get the data to display how i require.

 

I appreciate your help.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Ahmedx
Super User
Super User

to know how to do this watch my video and  pbix File

List.Generate(()=>[DATEUSED],
(x)=> x<=[DATERETURNED],
(x)=> Date.AddDays(x,1))

 https://1drv.ms/v/s!AiUZ0Ws7G26RjHQb92gyVK8szXUS?e=E96kJl

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.