Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi all,
I have a table that looks like following:
Then I created a new table like:
New_Table =
VAR _SUMMARIZE = (FILTER(Table, Table[name1] = "X" && Table[name2] = "Y"),
Table[id_2],
Table[start_date],
"min_id", MIN(Table[id]),
"end_date", MIN(Table[end_date]))
Then I calculated the days and used the average in visuals:
days =
DATEDIFF(new_table[start_date], new_table[end_date], DAY)
days =
CALCULATE(AVERAGEX(Table, DATEDIFF(Table[start_date], Table[end_date], DAY)),
FILTER(Table, Table[name1] = "X" && Table[name2] = "Y"))
Thanks for ideas!
Many greetings.
Solved! Go to Solution.
Hi, @Pikachu-Power ;
I seem to understand your logic. I modified the following data to prevent accidents, and then only two measures need to be created.
days =
var _mindid=CALCULATE(MIN('Table'[id]),FILTER(ALL('Table'),[name1]="X"&&[name2]="Y"&&[id_ 2]=MAX('Table'[id_ 2])))
return
IF(MAX('Table'[id])=_mindid, DATEDIFF(MAX('Table'[start_ date]),MAX('Table'[end_ date]),DAY))
day average = AVERAGEX('Table',[days])
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Pikachu-Power ;
I seem to understand your logic. I modified the following data to prevent accidents, and then only two measures need to be created.
days =
var _mindid=CALCULATE(MIN('Table'[id]),FILTER(ALL('Table'),[name1]="X"&&[name2]="Y"&&[id_ 2]=MAX('Table'[id_ 2])))
return
IF(MAX('Table'[id])=_mindid, DATEDIFF(MAX('Table'[start_ date]),MAX('Table'[end_ date]),DAY))
day average = AVERAGEX('Table',[days])
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Great! Interesting approach. I get the same values as in the new created table.
Hi, @Pikachu-Power ;
Modify it.
day average = AVERAGEX(SUMMARIZE('Table','Table'[id_ 2],"1",[minid]),[minid])
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
something is strange 😐 we dont use days. at the end it should be days instead of minid. but then we get the same wrong results before. the right results in .pbix are coincidence.
Hi, @Pikachu-Power ;
Based on my simple files and data, can you share the results you expect to produce?
Only average for the restrictions with X, Y and MIN (as if i have created a new table):
On a card we would like to see 1+4+5 / 3 = 3,33
But maybe to create a new table is indeed the best way to do that?
Hi, @Pikachu-Power ;
As minid ,you could try it.
minid = CALCULATE(MIN('Table'[id]),FILTER(ALL('Table'),[name1]="X"&&[name2]="Y"&&[id_ 2]=MAX('Table'[id_ 2])))
and about averge days:
days = DATEDIFF(MAX('Table'[start_ date]),MAX('Table'[end_ date]),DAY)
day average = AVERAGEX(FILTER(ALL('Table'),[name1]="X"&&[name2]="Y"&&[id_ 2]=MAX('Table'[id_ 2])),[days])
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Good idea but i dont see the consideration of MIN(Table[id]) in your formula. I added it but unfortunately i get different results as if i create a new table.
@community support
The day average dont respect MIN(Table[id]). For example in first row we have in average 1 day and not 2. And at the end i would need the number in a card... it looks like that the calculation works only in a table.
@Pikachu-Power , Try like
New measure =
AverageX( SUMMARIZE(FILTER(Table, Table[name1] = "X" && Table[name2] = "Y"),
Table[id_2],
Table[start_date],
"_end_date", MIN(Table[end_date])) , datediff([Start_date], [_end_date], day))
Or
New measure =
AverageX( SUMMARIZE(FILTER(Table, Table[name1] = "X" && Table[name2] = "Y"),
Table[id_2],
"_start_date", MIN(Table[start_date]),
"_end_date", MIN(Table[end_date])) , datediff([_Start_date], [_end_date], day))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
88 | |
86 | |
68 | |
51 | |
32 |
User | Count |
---|---|
126 | |
111 | |
72 | |
64 | |
46 |