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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
anubhav247
Regular Visitor

Find Aging given if an item has been sold or not in the past few Weeks

Hi BI Masters,

 

I have following data which shows if a particular item was sold in the past few week.

 

itemSoldHistory Weeks
AppleYes1
Appleyes2
AppleYes3
AppleYes4
AppleYes5
AppleYes6
AppleNo7
AppleYes8
AppleYes9
AppleYes10
AppleYes11
AppleYes12
OrangeYes1
Orangeyes2
OrangeYes3
OrangeNo4
OrangeYes5
OrangeYes6
OrangeNo7
OrangeYes8
OrangeYes9
OrangeYes10
OrangeYes11
OrangeYes12

 

I need to transform this dat into this

 

itemPerfection Ageing
Apple6
Orange3

 

By Looking at this data, anyone can tell that apple is being bought for last 6 weeks continuously and Orange is being Bought for last 3 weeks Continuosly.

 

I need to do this transformation in Power Query and Not Dax because this data will be refeenced by many other transformations.

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @anubhav247 ,

Here are the steps you can follow:

1. Add Column – Conditional Column – Look at the yellow label.

vyangliumsft_0-1678240814359.png

2. Transform – Group BY.

vyangliumsft_1-1678240771926.png

3. Add Column – Custom Column – Enter the following code.

vyangliumsft_2-1678240771928.png

4. Select [Count] – Remove Columns.

vyangliumsft_1-1678240840572.png

5. Result:

vyangliumsft_0-1678240905592.png

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @anubhav247 ,

Here are the steps you can follow:

1. Add Column – Conditional Column – Look at the yellow label.

vyangliumsft_0-1678240814359.png

2. Transform – Group BY.

vyangliumsft_1-1678240771926.png

3. Add Column – Custom Column – Enter the following code.

vyangliumsft_2-1678240771928.png

4. Select [Count] – Remove Columns.

vyangliumsft_1-1678240840572.png

5. Result:

vyangliumsft_0-1678240905592.png

 

Best Regards,

Liu Yang

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

anubhav247
Regular Visitor

***Adding info that might not be obvious***

 

Number "1" in History week column means last week, "2" means last to last week and so on

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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