Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Dear All, thank you for your time.
I have a request that seems really complicated to me, I don't know if it's achievable. I've recreeated the data I'm working with in a simplified table that I'm posting here below.
As you can see, I have different projects that at different dates ("mese" column), have different status.
The request is to calculate the number of months in which the project consecutively stays in "on hold", starting from the most recent. So for proj4 the result would be 2, for prog2, 1 and for prog1, 2.
I have tried in desktop with a measure,
Solved! Go to Solution.
Hello, @greta
let
Source = simplified_table,
z = Table.Group(
Source, {"prog"},
{{
"on_hold",
each List.PositionOf(
Table.Sort(_, {"index", Order.Descending})[status],
"on hold",
Occurrence.First,
(x, y) => x <> y
)
}}
)
in
z
@greta I did not consider the case when all values are On Hold. Try this instead:
let
Source = Lista_OnHold,
z = Table.Group(
Source, {"MercatusCode"},
{{
"On_Hold",
each
[lst = Table.Sort(_, {"Index.1", Order.Descending})[ProjectStatusInternal.1],
pozz = List.PositionOf(lst, "On Hold", Occurrence.First, (x, y) => x <> y),
zz = if pozz = -1 then List.Count(lst) else pozz][zz]
}}
)
in
z
Measure=CALCUATE(IF(MAXX(TOPN(1,Table,Table[index],DESC),Table[Status])="on hold",MAX(Table[index])-LASTNONBLANK(VALUES(Table[index]),IF(CALCULATE(MAX(Table[Status])="on hold",1))),ALLEXCPT(Table,Table[Project]))
Thank you very much for your support!
Hello, @greta
let
Source = simplified_table,
z = Table.Group(
Source, {"prog"},
{{
"on_hold",
each List.PositionOf(
Table.Sort(_, {"index", Order.Descending})[status],
"on hold",
Occurrence.First,
(x, y) => x <> y
)
}}
)
in
z
I've adapted the query to the following dataset,
As follows:
Could you help me in understanding why?
Many thanks in advance
@greta I did not consider the case when all values are On Hold. Try this instead:
let
Source = Lista_OnHold,
z = Table.Group(
Source, {"MercatusCode"},
{{
"On_Hold",
each
[lst = Table.Sort(_, {"Index.1", Order.Descending})[ProjectStatusInternal.1],
pozz = List.PositionOf(lst, "On Hold", Occurrence.First, (x, y) => x <> y),
zz = if pozz = -1 then List.Count(lst) else pozz][zz]
}}
)
in
z
Works perfectly, many thanks!