Forum Discussion
Exclude rows that have gaps in a time dimension
Hi,
I have the following problem:
I have a hierarchy with 2 levels (could be more in a real situation):
Region and Line:
| Region | Line |
| R1 | L1 |
| R1 | L3 |
| R2 | L2 |
| R2 | L4 |
In a fact table I have the following situation:
| ProdMonth | Region | Line | Uptime |
| 10/1/2017 | R1 | L1 | 10 |
| 11/1/2017 | R1 | L1 | 11 |
| 12/1/2017 | R1 | L1 | 12 |
| 1/1/2018 | R1 | L1 | 13 |
| 2/1/2018 | R1 | L1 | 14 |
| 3/1/2018 | R1 | L1 | 15 |
| 4/1/2018 | R1 | L1 | 16 |
| 5/1/2018 | R1 | L1 | 17 |
| 10/1/2017 | R2 | L2 | 20 |
| 11/1/2017 | R2 | L2 | 21 |
| 12/1/2017 | R2 | L2 | 22 |
| 1/1/2018 | R2 | L2 | 23 |
| 2/1/2018 | R2 | L2 | 24 |
| 3/1/2018 | R2 | L2 | 25 |
| 4/1/2018 | R2 | L2 | 26 |
| 5/1/2018 | R2 | L2 | 27 |
| 10/1/2017 | R1 | L3 | 30 |
| 11/1/2017 | R1 | L3 | 31 |
| 12/1/2017 | R1 | L3 | 32 |
| 1/1/2018 | R1 | L3 | 33 |
| 2/1/2018 | R1 | L3 | 34 |
| 3/1/2018 | R1 | L3 | 35 |
| 5/1/2018 | R1 | L3 | 37 |
| 10/1/2017 | R2 | L4 | 40 |
| 11/1/2017 | R2 | L4 | 41 |
| 12/1/2017 | R2 | L4 | 42 |
| 1/1/2018 | R2 | L4 | 43 |
| 2/1/2018 | R2 | L4 | 45 |
| 3/1/2018 | R2 | L4 | 46 |
| 5/1/2018 | R2 | L4 | 47 |
I need to calculate 6 month Trends for Uptime measure per Region.
But I need to include in the trends (lets suppose Avg(Uptime) just the Lines that have values for all 6 months.
In this case the trends for R1 should include just L1 and R2 just L2, because L3 and L4 have missing values for 4/1/2018.
How can I could achieve this?
The initial month for the trend has to be choose by an slicer.
I tried to think in calculated tables, but those are not impacted by a slicer.
Thanks for any idea!
Regards,
Alex
leverage on row context you will be able to exclude from calculation the item with missing data.
As example you can use:
CALCULATE(
AVERAGE(Fact[KPI]), FILTER(SUMMARIZE(Fact,Fact[Line] ,"a",DISTINCTCOUNT(Fact[ProdMonth])),[a]=CALCULATE(DISTINCTCOUNT(Fact[ProdMonth]),all(Fact[Line]))
)
)
2 Replies
- v-chuncz-msft
Community Support
- gipiluso
Resolver II
leverage on row context you will be able to exclude from calculation the item with missing data.
As example you can use:
CALCULATE(
AVERAGE(Fact[KPI]), FILTER(SUMMARIZE(Fact,Fact[Line] ,"a",DISTINCTCOUNT(Fact[ProdMonth])),[a]=CALCULATE(DISTINCTCOUNT(Fact[ProdMonth]),all(Fact[Line]))
)
)