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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

DAX function to count total number of reference per month i receive

To explain more clear my need, I have a sharepoint table called : "Liste receuil de consultation". I imported this table to power BI. In this table i have more than 10 columns. Below, we have two column of those more than 10. In the first column, we have reference number and in the second one, arrival date (the date we receive each reference). What i just want to do is, to visualise, the number of refence we receive per month and compare then. In "juin" for example we 2 references, in "Août", we receive 3. In "Sept", we receive 2 . etc....

 

Lagloire_0-1639500992178.png

 

Month# of reference
June2
August3
Sept2
Total7
2 ACCEPTED SOLUTIONS
bcdobbs
Community Champion
Community Champion

Hi,

 

I'll send a demo file over later this evening. However in brief:

 

1) Create a date table.

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

2) Link it to your date field.

 

3) You could then just drop reference id into a matrix with month from your date table and tell power bi to count. However a better way is to create a measure like:

Number of References = COUNTROWS( ReferenceTableName )

 

If you have more than one row per reference use

Number of References = DISTINCTCOUNT(ReferenceTableName[ReferenceId]



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

Demo File 

 

DAX for Calendar table:

Dates = 
    VAR EarliestDate = MIN ( Reference[Date Arrivee] )
    VAR LatestDate = MAX ( Reference[Date Arrivee] )

    RETURN 
    ADDCOLUMNS(
        CALENDAR( 
            DATE ( YEAR( EarliestDate ), 1, 1 ), 
            DATE ( YEAR ( LatestDate ), 12, 31 )
        ),
    "Month", DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 1 ) // Format as mmmm yyyy
    )

 

DAX for Measure:

 

Number of References = COUNTROWS ( Reference )


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

5 REPLIES 5
bcdobbs
Community Champion
Community Champion

Hi,

 

I'll send a demo file over later this evening. However in brief:

 

1) Create a date table.

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

2) Link it to your date field.

 

3) You could then just drop reference id into a matrix with month from your date table and tell power bi to count. However a better way is to create a measure like:

Number of References = COUNTROWS( ReferenceTableName )

 

If you have more than one row per reference use

Number of References = DISTINCTCOUNT(ReferenceTableName[ReferenceId]



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Anonymous
Not applicable

Hi

 

Thanks for your reply. I will try your solution and will be waiting for the demo as well.

 

Best regards

Demo File 

 

DAX for Calendar table:

Dates = 
    VAR EarliestDate = MIN ( Reference[Date Arrivee] )
    VAR LatestDate = MAX ( Reference[Date Arrivee] )

    RETURN 
    ADDCOLUMNS(
        CALENDAR( 
            DATE ( YEAR( EarliestDate ), 1, 1 ), 
            DATE ( YEAR ( LatestDate ), 12, 31 )
        ),
    "Month", DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 1 ) // Format as mmmm yyyy
    )

 

DAX for Measure:

 

Number of References = COUNTROWS ( Reference )


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Anonymous
Not applicable

Hi

Thank you a lot. It's working perfectly.

Regards

Glad it's working. If you could mark as a solution I'd appreciate.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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