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
Daro68
Frequent Visitor

List of oneshot customers for a specific item

Hello everyone,

I am trying to find out how I can extract a list of customers that have bought specific products with a sales amount over 15000 (regardless of the quantity), only once a year.  This is what we call oneshots.  I was able to get to the 15000 part but then I got stuck extracting the oneshots. 

In the Result column in the below visual I tried to show what I mean.  All data are in the same table so there are no relationships to be made here.

 

Thank you so much for your help.

 

Daro68_0-1674201531984.png

 

1 ACCEPTED SOLUTION
Daro68
Frequent Visitor

Hello ynigynir,

 

I think I found the solution based on your proposal.  instead of DISTINCTCOUNT the LineAmount, I changed it to Document No.  And now the first tests are promising.

Daro68_2-1674658922817.png

 

So if you are ok with it, I'll go for that solution and send you my gratitude.

 

 

View solution in original post

10 REPLIES 10
CNENFRNL
Community Champion
Community Champion

CNENFRNL_1-1674208290364.png

 

CNENFRNL_0-1674208246109.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

This was really going the right way, until I stumbled upon the DocumentNo what FreemanZ is asking me about.  Your solution is exactly what I need but on my mistake I did not mention the fact that there can only be one Documentnumber per year.  I'm sorry I was not clear about that.  So there is indeed an extra column in my report which is the Documentnr.

Hi @Daro68 ,

In order to get a better understanding on your requirement and give you a suitable solution for you, could you please provide some raw data in the table 'Main Table' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Hello yingyinr,

 

Good thinking.  I have a pbix file ready for you here: https://drive.google.com/file/d/1Sa8RGRXE2TAu1sFte6we2PiYLKrJ5Rdn/view?usp=sharing

 

Hope you will be able to fetch it.

So if a customer in 2022 bought an item with a value of over $15.000, only once that year it is a oneshot for me. 

This is an example of what I am NOT looking for.  This customer bought an item for over $15.000 but he already bought the same item for a lower amount.  So this is not a Oneshot. 

Daro68_0-1674485080534.png

 

My gratitude for your pro's is already greater than my PBI-issue right now.

 

Hi @Daro68 ,

I updated your sample pbix file, please check if that is what you want. You can create a calculated column as below to get it:

Column = 
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'OneshotTable'[Line Amount] ),
        FILTER (
            'OneshotTable',
            'OneshotTable'[Sell-to Customer No_]
                = EARLIER ( 'OneshotTable'[Sell-to Customer No_] )
                && 'OneshotTable'[Year] = EARLIER ( 'OneshotTable'[Year] )
                && 'OneshotTable'[No_] = EARLIER ( 'OneshotTable'[No_] )
        )
    )
RETURN
    IF ( _count > 1, "FALSE", "TRUE" )

yingyinr_0-1674551201279.png

If the above one is your expected result, please provide more special examples to explain your requirement. Thank you.

Best Regards

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

Hello yingyinr,

It was heading the right way but unfortunately I found an error in the results.  I found a customer that bought the same item for the same amount twice, so this can not be a oneshot.

Daro68_1-1674657398814.png

I am happy though that you were able to show me how to use the EARLIER function.  It didn't work for me previously.

But unfortunately this not the solution yet.

 

Daro68
Frequent Visitor

Hello ynigynir,

 

I think I found the solution based on your proposal.  instead of DISTINCTCOUNT the LineAmount, I changed it to Document No.  And now the first tests are promising.

Daro68_2-1674658922817.png

 

So if you are ok with it, I'll go for that solution and send you my gratitude.

 

 

Hi @Daro68 ,

Thanks for your feedback. I'm OK, please accept your last post as the solution. 😀

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
FreemanZ
Super User
Super User

hi @Daro68 

how does your order record table look like? Do you have something like order number?

Hi there,

Yes I have an order nr-column. Normally in Excel I solve this with a concat function, but in DAX, it is not that obvious. I even tried the 'EARLIER' function but it returned an error.

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.

Top Solution Authors