cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
H_insight
Helper III
Helper III

Lost Product

Hi All,

 

I am trying to identify lost product within my sample file for over 3 months ago. So All products thats meet the below criteria and over than 3 months old (rolling).

 

Criteria as follows: 1. product (col)= Production 2. Action (col) = View 3. Period is rolling last 3 months

 

Here is my DAX attempt:

Lost Product = 
VAR _Period = DATESINPERIOD(Data[Date],MAX(Data[Date]),-3,MONTH)
Return
CALCULATE(DISTINCTCOUNT(Data[Product]),NOT(Data[Date]) in _Period,FILTER(Data, Data[Product] ="Production"),FILTER(Data,Data[Action] = "View"))

 

The above dax return 1 record only, where I was expecting 4 records.

Any advice or tips would be much appreciated.

Sample file Link.

Thanks, H

1 ACCEPTED SOLUTION

Hi @H_insight ,

In my sample, Lost Product is a calculated column, I also create a measure in my sample, it cannot get the expected result, I attach it bellow to help you understand.

 

Best Regards,
Community Support Team _ kalyj

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

8 REPLIES 8
v-kalyj-msft
Community Support
Community Support

Hi @H_insight ,

According to your description, heres my solution. Lost Product is a column. as in the visual, the same options are not displayed repeatedly, so they add up to 3.

vkalyjmsft_0-1636940209474.png

 

Best Regards,
Community Support Team _ kalyj

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

Hi @v-kalyj-msft 

 

How can you refrence columns in the IF functions as it shows as error? unless you want me to creat a calculated column?

 

HeshamK_0-1636973196527.png

 

 

 

Lost Product 3 = 
VAR _Period =
    DATESINPERIOD ( Data[Date], MAX ( Data[Date] ), -3, MONTH )
RETURN
IF( 'Data'[Product] = "Production" && Data[Action] = "View" && NOT('Data'[Date]) IN _Period,1,
    IF( 'Data'[Product] = "Production" && Data[Action] = "View",0,BLANK()))

 

 

Hi @H_insight ,

In my sample, Lost Product is a calculated column, I also create a measure in my sample, it cannot get the expected result, I attach it bellow to help you understand.

 

Best Regards,
Community Support Team _ kalyj

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

Hi @v-kalyj-msft ,

 

Thanks again for your attempt, much appreciated. I realised the measure won't get me the expected result. For now I will accept this as a soultion.

 

Thanks, H

smpa01
Super User
Super User

@H_insight  Did you need this?

 

smpa01_0-1636548883962.png

 

Lost Product = 
VAR _Period =
    DATESINPERIOD ( Data[Date], MAX ( Data[Date] ), -3, MONTH )
RETURN
    CALCULATE (
        COUNTROWS ( Data ),
        NOT ( Data[Date] ) IN _Period,
        FILTER ( Data, Data[Product] = "Production" && Data[Action] = "View" )
    )

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






New Animated Dashboard: Sales Calendar


Hi @smpa01 

 

It works fine, but when I drag the date column nothing shows, any idea?

 

HeshamK_0-1636551418039.png

Thanks, H

@H_insight  can you please provide your desired output clearly?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






New Animated Dashboard: Sales Calendar


Expected outcome like this:

HeshamK_0-1636552414172.png

 

with the new measure the output shows the correct result (4 records) but when I add "Date" column, nothing shows in PBI.

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors