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
Sudharsanan
Helper III
Helper III

Finding the product which sold in the years 2022 & 2023

HI Friends,

 

Could someone help me with  my scenerio please? i need to find the product which shows in the year 2022 & 2023. Third coulmn is the result i am expecting using dax.

 

ProdustYearSold both year
A2022X
B2023X
C2023 
D2023 
A2023X
B2023X

 

thanks in advance for your help!!

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

and if you write like this, it solves your problem
Screen Capture #643.png

View solution in original post

12 REPLIES 12
Ahmedx
Super User
Super User

and if you write like this, it solves your problem
Screen Capture #643.png

OliverO
Helper II
Helper II

again, you didn't demonstrate that in your dataset

OliverO
Helper II
Helper II

am I missing something?  It shows both years in the picture??

sorry @OliverO i am not able to pull all the scenerio. i come to know only after applying the code and reviewing the result.

try with the below data set. the product C is in 2 rows but the year in 2023 for both, so we no need to mark "X" here

ProdustYearDateSold both year
A202203/17/2022X
A202203/16/2022X
B202303/17/2023X
C202303/16/2023 
C202303/17/2023 
D202203/16/2022 
A202303/17/2023X
B202203/16/2022X

 

Ahmedx
Super User
Super User

Screen Capture #639.png

Thank you @Ahmedx 

 

this code is working partially and the Product check is not working as expected. for example, the product should be in both 2023 and 2022 to mark "X".

 

thanks for your support.

OliverO
Helper II
Helper II

you should always put down a representative data set so people don't waste time solving the wrong problem

sorry about that @OliverO 

 

Hope the below data helps.

 

ProdustYearDateSold both year
A202203/17/2022X
A202203/16/2022X
B202303/17/2023X
C202303/17/2023 
D202203/16/2022 
A202303/17/2023X
B202203/16/2022X
OliverO
Helper II
Helper II

Try this

M1 =
IF (
CALCULATE (
    COUNT ( T2[Product] ),
    ALL ( T2 ),
    SUMMARIZE (
        T2,
        T2[Product]
    )
) > 1, "X", "")

Thank you @OliverO ,

 

with the give code we are not checking the year anywhere. this will work when i have only 1 row for 2022 or 2023.. but i have a scenerio where i can have the same product multiple times in the same year with different date. so checking year is mandate for me

Ahmedx
Super User
Super User

Sold both year = IF([Produst] in {"A","B"}&&[Year] in {2022,2023},"X")

Screen Capture #636.png

@Ahmedx thanks for the quick response..

can i refer a coulmn instead of {"A","B"}, because the product list is not restricted with A or B.

 

Thanks again

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.