Forum Discussion

vjnvinod's avatar
vjnvinod
Icon for Impactful Individual rankImpactful Individual
7 years ago
Solved

Tricky Power BI question

Dear Community,   Below is my table in the Page 1 of power BI sofware   SL TP AD 311628 AS 137153 CB -65774 TA 117019 Tx 152892 Total 652918   I need 2 solutions ...
  • Stachu's avatar
    Stachu
    7 years ago

    I think the issue was with scenario where there is only 1 entry meeting the criteria, try this code

    Measure = 
    VAR _Summary = ADDCOLUMNS(VALUES('Table'[SL]),"Value",[TP_SUM],"%",[Running %])
    VAR _Top2 = TOPN(2,_Summary,[%],DESC)
    VAR _FirstValue = MAXX(_Top2,[%])
    VAR _FirstName = FILTER(_Top2,[%]=_FirstValue) 
    VAR _SecondValue = MINX(_Top2,[%])
    VAR _SecondName = FILTER(_Top2,[%]=_SecondValue)
    RETURN
    CONCATENATEX(_FirstName,[SL]) & " constitute " & FORMAT(_FirstValue, "Percent") & " of total pipeline value, followed by " & CONCATENATEX(_SecondName,[SL]) & " " & FORMAT(_SecondValue, "Percent")