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

Average entries by month, week and day

I would like to know, given a certain date range, how many entries do I have, on average, per day, week and month.

So far I am creating three measures like this

 

average_ticket_perDay =

var nOfDays = DATEDIFF(Min(issues[created]), Max(issues[created]),Day)

var nOfRows = COUNTROWS(Issues)

Return DIVIDE(nOfRows,nOfDays)

 

average_ticket_perWeek =

var nOfWeeks = DATEDIFF(Min(issues[created]), Max(issues[created]),Week)

var nOfRows = COUNTROWS(Issues)

Return DIVIDE(nOfRows,nOfWeeks)

 

average_ticket_perMonth =

var nOfMonths = DATEDIFF(Min(issues[created]), Max(issues[created]),Month)

var nOfRows = COUNTROWS(Issues)

Return DIVIDE(nOfRows,nOfMonths)

 

And then I put three visuals with the tree informations.

 

Question:

Is it possibile to get this information only with a single visual?

Alternative question:

Is it possible to create only one measure and the DateDiff interval changes Dinamically?

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @fabiomanniti 

 

According to your description, I think you can create a singe table column as slicer, then you can choose day,week,month you want to control the result dynamically.

Like this:

average_ticket =
VAR nOfRows =
    COUNTROWS ( Issues )
VAR nOfDays =
    DATEDIFF ( MIN ( issues[created] ), MAX ( issues[created] ), DAY )
VAR nOfWeeks =
    DATEDIFF ( MIN ( issues[created] ), MAX ( issues[created] ), WEEK )
VAR nOfMonths =
    DATEDIFF ( MIN ( issues[created] ), MAX ( issues[created] ), MONTH )
VAR nofRD =
    DIVIDE ( nOfRows, nOfDays )
VAR nofRW =
    DIVIDE ( nOfRows, nOfWeeks )
VAR nofRM =
    DIVIDE ( nOfRows, nOfMonths )
RETURN
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( table[date] ) = "Day", nofRD,
        SELECTEDVALUE ( table[date] ) = "Week", nofRW,
        SELECTEDVALUE ( table[date] ) = "Month", nofRM
    )

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Community Support Team _ Janey

View solution in original post

1 REPLY 1
v-janeyg-msft
Community Support
Community Support

Hi, @fabiomanniti 

 

According to your description, I think you can create a singe table column as slicer, then you can choose day,week,month you want to control the result dynamically.

Like this:

average_ticket =
VAR nOfRows =
    COUNTROWS ( Issues )
VAR nOfDays =
    DATEDIFF ( MIN ( issues[created] ), MAX ( issues[created] ), DAY )
VAR nOfWeeks =
    DATEDIFF ( MIN ( issues[created] ), MAX ( issues[created] ), WEEK )
VAR nOfMonths =
    DATEDIFF ( MIN ( issues[created] ), MAX ( issues[created] ), MONTH )
VAR nofRD =
    DIVIDE ( nOfRows, nOfDays )
VAR nofRW =
    DIVIDE ( nOfRows, nOfWeeks )
VAR nofRM =
    DIVIDE ( nOfRows, nOfMonths )
RETURN
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( table[date] ) = "Day", nofRD,
        SELECTEDVALUE ( table[date] ) = "Week", nofRW,
        SELECTEDVALUE ( table[date] ) = "Month", nofRM
    )

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Community Support Team _ Janey

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.