Table is Empty - Power Query

AllisterB

Board Regular
Joined
Feb 22, 2019
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Hi

I want to test in a Power Query if the Excel Table (t_AccrTrialBalance) is empty. If so then display a message and stop the Query otherwise do the transformation. how do I do this ?

Thank You


My code at present is
let
Source = Excel.CurrentWorkbook(){[Name="t_AccrTrialBalance"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type any}, {"Column3", type text}, {"Column4", type text}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}}),
#"Removed Top Rows" = Table.Skip(#"Changed Type",5),
#"Transposed Table" = Table.Transpose(#"Removed Top Rows"),
#"Cleaned Text" = Table.TransformColumns(#"Transposed Table",{{"Column1", Text.Clean, type text}}),
#"Transposed Table1" = Table.Transpose(#"Cleaned Text"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true]),

in
#"Promoted Headers"
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
it should work like this

data-vs-blank.gif
 
Upvote 0
Rich (BB code):
// Warning
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Warning = if Table.Profile(Source)[Count] = Table.Profile(Source)[NullCount] then "All values are null" else Base
in
    Warning

// Base
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Sales Order", "Make"}, {{"Count", each _, type table}}),
    Model = Table.AddColumn(Group, "Model", each List.Distinct([Count][Model])),
    ExtractModel = Table.TransformColumns(Model, {"Model", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    ExtractModel
two queries: Warning and Base. Warning is an "error" query, Base is your transformed query or whatever you want to do there.
from Warning you should call Base
after all you can load Base into the sheet
 
Last edited:
Upvote 0
correction:
after all you can load Base into the sheet
after all you can load Warning into the sheet
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,425
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top