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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Sri57
Frequent Visitor

DAX Query

Hello Experts,
I want to calculate average of a measure NR:

 

NR=VAR CurrentDate = MAX('Dim - Calendar'[Fiscal Year ID])


VAR result =
    CALCULATE(
        COUNTROWS('Audit'),
        FILTER(
            ALLEXCEPT('Audit', 'Audit'[NAME]),
            'Audit'[RATING] = "Needs Refinement" &&
            
            'Audit'[FISCAL_YEAR_ID] = CurrentDate
        ),
        CROSSFILTER('Dim - Calendar'[Date], 'Audit'[PLANNED_START], None)
    )

VAR max_notblank =
    CALCULATE(
        MAX('Audit'[FISCAL_YEAR_ID]),
        FILTER(
            ALLSELECTED('Audit'),
            'Audit'[FISCAL_YEAR_ID] < CurrentDate ||
            
            'Audit'[FISCAL_YEAR_ID] <> BLANK()
        ),
        CROSSFILTER('Dim - Calendar'[Date], 'Audit'[PLANNED_START], None)
    )

VAR result1 =
    CALCULATE(
        COUNTROWS('Audit'),
        FILTER(
            ALLEXCEPT('Audit', 'Audit'[NAME]),
            'Audit'[RATING] = "Needs Refinement" &&
            
             'Audit'[FISCAL_YEAR_ID] = max_notblank)
        ),
        CROSSFILTER('Dim - Calendar'[Date], 'Audit'[ENGAGEMENT_PLANNED_START], None)
    )
if(result = blank(),result1,result)

 

  for this I have written averagex(values(Audit[Name]),[NR]),
here it is getting only result value, eeven I have data for previous year for other names.

Sri57_0-1720568684474.png

here for the selected year we only have data for one name, but as per my measureNR, we have 5 records as it is checking previous year too.now I want average of NRlike(6+4+5+10+11)/5=7.2. As averagex is not working I tried to create two different measures like(sumof NR/countof NR),I succeded in creating sum of NR measure but not count of NR

please help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Sri57 ,

 

According to your description, here are my steps you can follow as a solution.

(1) We can create a measure. 

avg = 
var _count=COUNTROWS(ALLSELECTED('Table'))
var _nr=SUMX(ALLSELECTED('Table'),[NR])
RETURN DIVIDE(_nr,_count)

(2) Then the result is as follows.

vtangjiemsft_0-1720662984337.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

1 REPLY 1
Anonymous
Not applicable

Hi @Sri57 ,

 

According to your description, here are my steps you can follow as a solution.

(1) We can create a measure. 

avg = 
var _count=COUNTROWS(ALLSELECTED('Table'))
var _nr=SUMX(ALLSELECTED('Table'),[NR])
RETURN DIVIDE(_nr,_count)

(2) Then the result is as follows.

vtangjiemsft_0-1720662984337.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Users online (2,195)