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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
KV2022
Helper II
Helper II

average of a measure over a dimension along the time axis

Hi, I have data like this 

KV2022_0-1669103652720.png

 

I need a graph like this 

KV2022_2-1669103059005.png

Please help.  I have to show average of TAT days by stage name along the time axis .

Days at stage in the 2nd graph = TAT days in the data table

stage in the 2nd graph = stg_nm in the table

TAT days is calculated from fact

Stg_nm, - comes from dimension(which has dim_proj_stg_key)  which is connected to dim_proj_stg_key in fact

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

Hi @KV2022 ,

 

This is my test fact table:

vyadongfmsft_0-1669188690151.png

 

Dim table:

vyadongfmsft_1-1669188715721.png

 

Create two measures:

TAT =
CALCULATE (
    DATEDIFF ( MIN ( [Date] ), MAX ( [Date] ), DAY ),
    FILTER (
        'Fact',
        'Fact'[dim_proj_stg_key] = SELECTEDVALUE ( 'Fact'[dim_proj_stg_key] )
            && 'Fact'[YearMonth] = SELECTEDVALUE ( 'Fact'[YearMonth] )
    )
)


Average_TAT =
AVERAGEX (
    FILTER (
        ALL ( 'Fact'[YearMonth] ),
        'Fact'[YearMonth] = SELECTEDVALUE ( 'Fact'[YearMonth] )
    ),
    [TAT]
)

 

I think this is the result you want:

vyadongfmsft_2-1669189013695.png

 

If I misunderstand your demands, please share with me some screenshots of your data after hiding sensitive information and tell me what's your expected output.

 

Best regards,

Yadong Fang

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-yadongf-msft
Community Support
Community Support

Hi @KV2022 ,

 

This is my test fact table:

vyadongfmsft_0-1669188690151.png

 

Dim table:

vyadongfmsft_1-1669188715721.png

 

Create two measures:

TAT =
CALCULATE (
    DATEDIFF ( MIN ( [Date] ), MAX ( [Date] ), DAY ),
    FILTER (
        'Fact',
        'Fact'[dim_proj_stg_key] = SELECTEDVALUE ( 'Fact'[dim_proj_stg_key] )
            && 'Fact'[YearMonth] = SELECTEDVALUE ( 'Fact'[YearMonth] )
    )
)


Average_TAT =
AVERAGEX (
    FILTER (
        ALL ( 'Fact'[YearMonth] ),
        'Fact'[YearMonth] = SELECTEDVALUE ( 'Fact'[YearMonth] )
    ),
    [TAT]
)

 

I think this is the result you want:

vyadongfmsft_2-1669189013695.png

 

If I misunderstand your demands, please share with me some screenshots of your data after hiding sensitive information and tell me what's your expected output.

 

Best regards,

Yadong Fang

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

Hi, thanks for the reply.  I am getting result like this. 

The TAT and Average TAT are same for every stage. 

In the data model, the stage names can be duplicate in fact meaning the stages can have iterations for every month. 

The last 2 columns  in this picture below  are minimum iteration and max iteration for a stage in a month. for eg; in Oct 2017, publisher check stage has 2 iteration. So the average should be 8 TAT days average to 4 days for 2 iterations in the stage.

But Average TAT is same as TAT . Is this correct? 

Average_TAT =
AVERAGEX (
    FILTER (
        ALL ( dim_dt[MonthYear] ),
        dim_dt[MonthYear] = SELECTEDVALUE ( dim_dt[MonthYear] )
    ),
    [TAT(Days)]
)KV2022_4-1669608101740.png

 

Thanks.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

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.