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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Transcribe formula DAX into PowerQuery

Good afternoon!

I'm having trouble finding an alternative to the following problem:

I'm working with data import through BigQuery and due to the large amount of data it becomes viable to import via DirectQuery and not by import.

However, I need a column that I was able to do only in DAX, through the formula:

 

liq7diasAntes =

VAR chave7diasAntes = baseVendasSAC[chave7DiasAntes]

RETURN

CALCULATE(SUM(baseVendasSAC[Vlr. Líquido]), FILTER(baseVendasSAC, baseVendasSAC[chaveDia] = chave7diasAntes))

 

Through DirectQuery it is not possible to add columns via DAX, it does not have the data environment.

Is it possible to do the same function of this formula via PowerQuery or is it somehow accepted via DirectQuery?

Thanks in advance!

PHELDMAN_0-1651080335964.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please follow:

Eyelyn9_3-1651484131390.pngEyelyn9_4-1651484156413.png

Then expand necessary columns:

Eyelyn9_2-1651484086576.png

Bleow is the whole M syntax:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSAWNDpVidaCUnIMsZiI3APBcgyxWIjcE8NyALhE3APJg+U6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [chave7DiasAntes = _t, chaveDia = _t, #"Vlr. Líquido" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"chave7DiasAntes", type text}, {"chaveDia", type text}, {"Vlr. Líquido", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"chave7DiasAntes"}, {{"Count", each _, type table [chave7DiasAntes=nullable text, chaveDia=nullable text, Vlr. Líquido=nullable number, Custom=number]}}),
    #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom", each List.Sum(Table.SelectRows([Count],each [chaveDia]=[chave7DiasAntes])[Vlr. Líquido])),
    #"Expanded Count" = Table.ExpandTableColumn(#"Added Custom1", "Count", {"chave7DiasAntes", "chaveDia", "Vlr. Líquido"}, {"chave7DiasAntes.1", "chaveDia", "Vlr. Líquido"})
in
    #"Expanded Count"

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Please follow:

Eyelyn9_3-1651484131390.pngEyelyn9_4-1651484156413.png

Then expand necessary columns:

Eyelyn9_2-1651484086576.png

Bleow is the whole M syntax:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSAWNDpVidaCUnIMsZiI3APBcgyxWIjcE8NyALhE3APJg+U6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [chave7DiasAntes = _t, chaveDia = _t, #"Vlr. Líquido" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"chave7DiasAntes", type text}, {"chaveDia", type text}, {"Vlr. Líquido", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"chave7DiasAntes"}, {{"Count", each _, type table [chave7DiasAntes=nullable text, chaveDia=nullable text, Vlr. Líquido=nullable number, Custom=number]}}),
    #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom", each List.Sum(Table.SelectRows([Count],each [chaveDia]=[chave7DiasAntes])[Vlr. Líquido])),
    #"Expanded Count" = Table.ExpandTableColumn(#"Added Custom1", "Count", {"chave7DiasAntes", "chaveDia", "Vlr. Líquido"}, {"chave7DiasAntes.1", "chaveDia", "Vlr. Líquido"})
in
    #"Expanded Count"

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

wdx223_Daniel
Community Champion
Community Champion

NewStep=let a=Table.Buffer(Table.Group(baseVendasSAC,"chaveDia",{"amt",each List.Sum([Vlr. Líquido])})) in Table.AddColumn(baseVendasSAC,"liq7diasAntes",each a{[chaveDia=[chave7DiasAntes]]}?[amt]?)

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.