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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
MarianoV
Frequent Visitor

How to make the total average number of days appear?

Hi! I have a measure where it calculates the average number of days from the user's previous purchase date to the next purchase date. However, the total does not appear in the table. I have another measure which on the other hand, calculates the average number of days from the user's first session to their first purchase and there is a total for that. However, I cannot do it for the other measure. Here's my calculation for AvgDaysBeforePurchase.

MarianoV_0-1737557667242.png

 



AvgDaysBeforePurchase =
VAR CurrentDate = SELECTEDVALUE('Transactions'[Date])
VAR PrevDate = CALCULATE(MAX('Transactions'[Date]),FILTER(ALL('Transactions'),'Transactions'[Date] < CurrentDate && 'Transactions'[user_pseudo_id] = SELECTEDVALUE('Transactions'[user_pseudo_id])))

RETURN
    AVERAGEX(
        VALUES('Transactions'[user_pseudo_id]),
        DATEDIFF(
            IF(ISBLANK(PrevDate), SELECTEDVALUE('Transactions'[firstSessionDate]), PrevDate),
            CurrentDate,
            DAY
        )
    )
2 REPLIES 2
MarianoV
Frequent Visitor

Hi! It worked but taking so long to load, and i dont know why, but when I use other rows (other than userID), values are not showing.

What I did instead is I created a calculated column, then added it in the table as Average. Would that suffice? 

P.S. Blanks are those users that do not have other purchases, whereas those with values in the Average of DaysBeforePurchase are based from the same user's previous transaction.

MarianoV_0-1737643510132.png

 

Anonymous
Not applicable

Hi  @MarianoV ,

 

The Total total value will change with the formula in the measure, it could be that your formula is setting the total value to null, you can create a measure and use IF() + HASONEVALUE() to determine if it's total, if it is, customize the aggregation rule, if it's not, then display [AvgDaysBeforePurchase].

AvgDaysBeforePurchase =
IF(
    HASONEVALUE('Transactions'[user_pseudo_id]),MAX('Transactions'[Value]),BLANK())

vyangliumsft_0-1737594801972.png

 

If the results do not meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.