Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Allan-Mautante
Frequent Visitor

Excel Formula to Power Bi

Hi Folks,

 

Need your Help on  convert this Excel formula to Dax Power BI fformula.

I allready tried searching but doesn't work.

 

Validitor = Unique Value

Date/Hour= Date of Call

 

 

Allan-Mautante_0-1614417672933.png

 

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Allan-Mautante 

 

i can show you how to write these formulas in Power Query, but sometimes this is not the best approach, because Power Query is not Excel after all. 

ISBLANK = 
   [ColumnReference]=null
    or
    [Columnreference]="" depending if your column is empty cell or null

IFERROR = 
    surround your function with try ... yourfunction .... otherwise HereComesFunctionWhenFirstPartGivesError

IF(...,...,...)=
   if check then yourCodeIfCheck=True else yourCodeIfCheck=False

INDEX(MATCH)=
   these kind of function is not existing in Power Query but there is a better alternative and is Table.NestedJoin or Table.Join

I also dont know if your relative cell reference in INDEX or MATCH is intended and needed (basically your cell S4 its changed to S5 in the next row--> is that needed?).  And I really think that is needed --> then you can't use Table.NestedJoin but you would need to go for Table.SelectRows instead and you need to add a Index-column as well. 

Here the formula

Table.AddColumn(AddedIndex, "YourFormula", each try if [C]="" then "" else Table.SelectRows(AddedIndex, (sel)=> sel[Index]>[Index] and sel[S]=[S])[A]{0} otherwise "")

Here the complete code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCsovd1TSUQIiE6VYHTDfCcipAGJTmIAzVMAMJuCCUBELAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, C = _t, S = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"C", type text}, {"S", Int64.Type}}),
    AddedIndex = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
    #"Added Custom" = Table.AddColumn(AddedIndex, "YourFormula", each try if [C]="" then "" else Table.SelectRows(AddedIndex, (sel)=> sel[Index]>[Index] and sel[S]=[S])[A]{0} otherwise "")
in
    #"Added Custom"

transforms this

Jimmy801_0-1614440828607.png

into this

Jimmy801_1-1614440844410.png

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

1 REPLY 1
Jimmy801
Community Champion
Community Champion

Hello @Allan-Mautante 

 

i can show you how to write these formulas in Power Query, but sometimes this is not the best approach, because Power Query is not Excel after all. 

ISBLANK = 
   [ColumnReference]=null
    or
    [Columnreference]="" depending if your column is empty cell or null

IFERROR = 
    surround your function with try ... yourfunction .... otherwise HereComesFunctionWhenFirstPartGivesError

IF(...,...,...)=
   if check then yourCodeIfCheck=True else yourCodeIfCheck=False

INDEX(MATCH)=
   these kind of function is not existing in Power Query but there is a better alternative and is Table.NestedJoin or Table.Join

I also dont know if your relative cell reference in INDEX or MATCH is intended and needed (basically your cell S4 its changed to S5 in the next row--> is that needed?).  And I really think that is needed --> then you can't use Table.NestedJoin but you would need to go for Table.SelectRows instead and you need to add a Index-column as well. 

Here the formula

Table.AddColumn(AddedIndex, "YourFormula", each try if [C]="" then "" else Table.SelectRows(AddedIndex, (sel)=> sel[Index]>[Index] and sel[S]=[S])[A]{0} otherwise "")

Here the complete code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCsovd1TSUQIiE6VYHTDfCcipAGJTmIAzVMAMJuCCUBELAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, C = _t, S = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"C", type text}, {"S", Int64.Type}}),
    AddedIndex = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
    #"Added Custom" = Table.AddColumn(AddedIndex, "YourFormula", each try if [C]="" then "" else Table.SelectRows(AddedIndex, (sel)=> sel[Index]>[Index] and sel[S]=[S])[A]{0} otherwise "")
in
    #"Added Custom"

transforms this

Jimmy801_0-1614440828607.png

into this

Jimmy801_1-1614440844410.png

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors