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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BenMagn
New Member

First occurence with multiple conditions

Hi, I am new to DAX and would like to create a measure that produce a column called [Rookie year] to count the first occurence of an individual that purchased an item based on other variables. 

 

those are the other conditions to be considered in order to be counted as first occurence : 

 

- His client number wich is unique to him and stay's the same year after year is called [N certificat]

- In the column [Statut certificat] It as to be "Permanent"

- The date of [Date certificat] as to be within 5 years of the date of purchase wich is the column [Date emission permis] in order to count

 

So each [N certificat] as to appear only once in the column rookie year.

 

see picture below for a more visual look of an example table. the datas are not the real datas so the occurence dont match.

 

BenMagn_0-1674246276067.png

 

Ive fiddled with some of the formulas found in the forum but couldnt find one that I am able to translate to my needs. 

 

Thanks very much !

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @BenMagn ,

I created a sample pbix file(see the attachment), please check if that is what you want. You can create a measure as below to get it:

Rookie year = 
VAR _selncer =
    SELECTEDVALUE ( 'Table'[N certificat] )
VAR _mindep =
    CALCULATE (
        MIN ( 'Table'[Date emission permis] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[N certificat] = _selncer )
    )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[N certificat] ),
        FILTER (
            'Table',
            'Table'[N certificat] = _selncer
                && 'Table'[Date emission permis] = _mindep
                && 'Table'[Statut certificat] = "Permanent"
                && 'Table'[Date emission permis] - 'Table'[Date certificat] <= 5
        )
    )
RETURN
    IF ( _selncer IN _tab, 1, 0 )

yingyinr_0-1674546750922.png

If the above one can't help you, could you please provide more raw data in your tables (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

View solution in original post

3 REPLIES 3
BenMagn
New Member

Hope this is easier to understand ! thanks!

BenMagn_2-1674482932971.png

 

 

 

Anonymous
Not applicable

Hi @BenMagn ,

I created a sample pbix file(see the attachment), please check if that is what you want. You can create a measure as below to get it:

Rookie year = 
VAR _selncer =
    SELECTEDVALUE ( 'Table'[N certificat] )
VAR _mindep =
    CALCULATE (
        MIN ( 'Table'[Date emission permis] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[N certificat] = _selncer )
    )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[N certificat] ),
        FILTER (
            'Table',
            'Table'[N certificat] = _selncer
                && 'Table'[Date emission permis] = _mindep
                && 'Table'[Statut certificat] = "Permanent"
                && 'Table'[Date emission permis] - 'Table'[Date certificat] <= 5
        )
    )
RETURN
    IF ( _selncer IN _tab, 1, 0 )

yingyinr_0-1674546750922.png

If the above one can't help you, could you please provide more raw data in your tables (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

FreemanZ
Super User
Super User

hi @BenMagn 

Unable to understand your expectation, could you provide also the expected result?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.