March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello community,
I have a table like this (the bold text shows just the group size = 3 rows):
Date | PRUEF | NUMBER | MATNR | fci |
01.07.2024 | 9E+10 | 20129061 | 10089563 | 40,9 |
01.07.2024 | 9E+10 | 20212642 | 10101425 | 37 |
01.07.2024 | 9E+10 | 20136950 | 10089625 | 46,4 |
02.07.2024 | 9E+10 | 20136971 | 10089487 | 52 |
02.07.2024 | 9E+10 | 20129061 | 10089563 | 46,1 |
02.07.2024 | 9E+10 | 20136971 | 10089487 | 31,7 |
03.07.2024 | 9E+10 | 20136972 | 10089655 | 55 |
05.07.2024 | 9E+10 | 20086281 | 10091391 | 46,4 |
04.07.2024 | 9E+10 | 20086185 | 10089212 | 23,5 |
04.07.2024 | 9E+10 | 20129061 | 10089563 | 50,5 |
04.07.2024 | 9E+10 | 20129061 | 10089563 | 44,8 |
04.07.2024 | 9E+10 | 20129061 | 10089563 | 56,4 |
05.07.2024 | 9E+10 | 20201962 | 10096433 | 53,3 |
And added here the desired columns
lfd Num | Date | PRUEF | NUMBER | MATNR | fci | 3xAVG | Distinct count | AVG same products | new 3xAVG |
1 | 01.07.2024 | 9E+10 | 20129061 | 10089563 | 40,9 | 1 | |||
2 | 01.07.2024 | 9E+10 | 20212642 | 10101425 | 37 | 41,43 | 1 | 41,43 | |
3 | 01.07.2024 | 9E+10 | 20136950 | 10089625 | 46,4 | 1 | |||
4 | 02.07.2024 | 9E+10 | 20136971 | 10089487 | 52 | 2 | 41,85 | ||
5 | 02.07.2024 | 9E+10 | 20129061 | 10089563 | 46,1 | 43,27 | 1 | 43,98 | |
6 | 02.07.2024 | 9E+10 | 20136971 | 10089487 | 31,7 | 2 | 41,85 | ||
7 | 03.07.2024 | 9E+10 | 20136972 | 10089655 | 55 | 1 | |||
8 | 05.07.2024 | 9E+10 | 20086281 | 10091391 | 46,4 | 41,63 | 1 | 41,63 | |
9 | 04.07.2024 | 9E+10 | 20086185 | 10089212 | 23,5 | 1 | |||
10 | 04.07.2024 | 9E+10 | 20129061 | 10089563 | 50,5 | 3 | |||
11 | 04.07.2024 | 9E+10 | 20129061 | 10089563 | 44,8 | 50,57 | 3 | 50,57 | 50,57 |
12 | 04.07.2024 | 9E+10 | 20129061 | 10089563 | 56,4 | 3 | |||
13 | 05.07.2024 | 9E+10 | 20201962 | 10096433 | 53,3 | 1 |
I was able to add some of the required columns with visual calulations, unfortunately it is not possible then to export the view to csv/excel.
lfd Num = FORMAT(RANK(DENSE,ROWS), "#")
3xAVG =
VAR _rang = FORMAT(RANK(DENSE,ROWS), "#")
VAR GroupSize = 3
RETURN
IF(MOD(_rang, GroupSize) = 2,
DIVIDE(( [fci] + NEXT([fci]) + PREVIOUS([fci])),3),
But now I am stuck at the counting the distinct MATNR in each group and the following columns.
It would be great if you could advise the measures to get rid of the visual calculations.
Thank you
Solved! Go to Solution.
Hi @Pillic
I change the measures to the following,you can refer to.
Mod = MOD([RankingIndex],3)
Group =
VAR a = [RankingIndex]
VAR b =
COUNTROWS (
FILTER ( ALLSELECTED ( 'Table' ), [RankingIndex] < a && [Mod] = 0 )
)
RETURN
IF ( b > 0, b, 0 )
Distinctcount =
VAR a = [Group]
RETURN
COUNTROWS (
FILTER (
ALLSELECTED ( 'Table' ),
[Group] = a
&& [MATNR] = MAX ( 'Table'[MATNR] )
)
)
AVG same products =
VAR a = [Group]
VAR b =
SUMX (
FILTER (
ALLSELECTED ( 'Table' ),
[Group] = a
&& [MATNR] = MAX ( 'Table'[MATNR] )
),
[fci]
)
RETURN
IF ( [Distinctcount] > 1, DIVIDE ( b, [Distinctcount] ) )
Then it can work.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Pillic
Based on your description, you can refer to the following solution.
I create an index column in table.
Then create the following measures.
Mod = MOD(MAX('Table'[Index]),3)
Group =
VAR a =
COUNTROWS (
FILTER (
ALLSELECTED ( 'Table' ),
[Index] < MAX ( 'Table'[Index] )
&& [Mod] = 0
)
)
RETURN
IF ( a > 0, a, 0 )
Distinctcount =
VAR a = [Group]
RETURN
COUNTROWS (
FILTER (
ALLSELECTED ( 'Table' ),
[Group] = a
&& [MATNR] = MAX ( 'Table'[MATNR] )
)
)
AVG same products =
VAR a = [Group]
VAR b =
SUMX (
FILTER (
ALLSELECTED ( 'Table' ),
[Group] = a
&& [MATNR] = MAX ( 'Table'[MATNR] )
),
[fci]
)
RETURN
IF ( [Distinctcount] > 1, DIVIDE ( b, [Distinctcount] ) )
Then create a table visual , put the distinctcount measure and the AVG same products measure to the visual.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-xinruzhu-msft
Hi and thank you, Yolo!
your solutions look very promising, although I am struggeling with the 1st step, the ranking (without the visual calculation).
In the table I do have an Index column, but that will become noncontinious after some filtering.
How did you created the ranking?
Hi @Pillic
Thanks for your quick reply, based in your descriotion, you can change yor ranking index measure to the following.
Measure =
RANKX (
ALLSELECTED ( LieferscheineUnique ),
CALCULATE ( SUM ( LieferscheineUnique[Index] ) ),
,
asc,
DENSE
)
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-xinruzhu-msft ,
thanks to your measure, I was able to create the rank like so:
RankingIndex =
IF(HASONEVALUE(LieferscheineUnique[fci_zu_PA]),
RANKX (
ALLSELECTED ( LieferscheineUnique ),
CALCULATE ( SUM ( LieferscheineUnique[Index] ) ),
,
asc,
DENSE
), BLANK())
But now the Group measure shows this:
Group =
VAR a =
COUNTROWS (
FILTER (
ALLSELECTED ( LieferscheineUnique ),
[RankingIndex] < MAX([RankingIndex])
&& [Mod] = 0
)
)
RETURN
IF ( a > 0, a, 0 )
Error:
The 'MAX' function only accepts a column reference as an argument.
It would be great, if you could help me out to fix this.
Thanks a lot for your help so far.
Hi @Pillic
I change the measures to the following,you can refer to.
Mod = MOD([RankingIndex],3)
Group =
VAR a = [RankingIndex]
VAR b =
COUNTROWS (
FILTER ( ALLSELECTED ( 'Table' ), [RankingIndex] < a && [Mod] = 0 )
)
RETURN
IF ( b > 0, b, 0 )
Distinctcount =
VAR a = [Group]
RETURN
COUNTROWS (
FILTER (
ALLSELECTED ( 'Table' ),
[Group] = a
&& [MATNR] = MAX ( 'Table'[MATNR] )
)
)
AVG same products =
VAR a = [Group]
VAR b =
SUMX (
FILTER (
ALLSELECTED ( 'Table' ),
[Group] = a
&& [MATNR] = MAX ( 'Table'[MATNR] )
),
[fci]
)
RETURN
IF ( [Distinctcount] > 1, DIVIDE ( b, [Distinctcount] ) )
Then it can work.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks a lot...that works like a charm now (although the performance while slicing is reduced, but I can live with that)
May I kindly ask, to also help with the last required column. Which equals basicly the
DIVIDE ( Average (AVG same products) + fci_zu_PA (where __Distinctcount = 1) , 2)
and all within each group.
Best Regards.
Hi @Pillic
You can try the following.
MEASURE =
VAR a = [Group]
VAR b =
MAXX ( FILTER ( ALLSELECTED ( 'Table' ), [Group] = a ), [AVG same products] )
VAR c =
MAXX (
FILTER ( ALLSELECTED ( 'Table' ), [Group] = a && [Distinctcount] = 1 ),
[fci]
)
RETURN
IF ( [Mod] = 2 && b > 0 && c > 0, DIVIDE ( b + c, 2 ), [3xAVG] )
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you so much for your help! your proposal works as acpected.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
126 | |
85 | |
69 | |
53 | |
44 |
User | Count |
---|---|
202 | |
106 | |
100 | |
64 | |
56 |