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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Avg LTD dax logic

Hi,

 i am not able to get the below output 'Avg LTD' - below screenshot

'LTD Qty' and 'all period count' columns should not depend on the slicer selection made.

ex- slicer period type=month period name=apr and may

LTD Qty = sum of all qty till date (may+apr+mar+feb=60 for group A), sum of all qty till date (may+apr+jan=80 for group B)

'all period count' - 4 for Group A(may,apr,mar,feb),  3 for Group B(may,apr,jan), 

should show count of all period name which has data for the respective group and period type slicer.

 

data is avilable below. need your help for solving this

 

image1.PNG

 

Period KeyPeriod TypePeriod NameDateGroupQty
1MonthMay12-MayA20
1MonthMay15-MayA5
1MonthApr7-AprA15
1MonthApr15-AprA10
1MonthMar23-MarA5
1MonthFeb11-FebA5
1MonthMay15-MayB20
1MonthApr10-AprB30
1MonthJan14-JanB30
2QtrQ212-MayA20
2QtrQ215-MayA5
2QtrQ27-AprA15
2QtrQ215-AprA10
2QtrQ123-MarA5
2QtrQ111-FebA5
2QtrQ215-MayB20
2QtrQ210-AprB30
2QtrQ114-JanB30

 

Thanks

Raj

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

Hi @Anonymous ,

 

Please try like this:

LTD Qty =
CALCULATE (
    SUM ( 'Table'[Qty] ),
    ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Period Type] )
)


all period count =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Period Name] ),
    ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Period Type] )
)

AVG = DIVIDE([LTD Qty],[all period count])

6.PNG

 

 

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

View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try like this:

LTD Qty =
CALCULATE (
    SUM ( 'Table'[Qty] ),
    ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Period Type] )
)


all period count =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Period Name] ),
    ALLEXCEPT ( 'Table', 'Table'[Group], 'Table'[Period Type] )
)

AVG = DIVIDE([LTD Qty],[all period count])

6.PNG

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous ,  Try like example given below with date table

 

Cumm Sales =

Var _max = maxx(allselected(date),date[date])

return

CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=_max ))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors