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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power Query Logic

Hi all,

I have to write the below sql query in dataflows advance editor

SELECT P.PPRT.PART, P.PUSH.P_COLM_1_,P.PPRT.C_HARMZD_PRE,P.PPRT.C_SUFF
FROM P.PPRT,  P.PUSH
WHERE CURRENT DATE Between P.PPRT.D_EFFCTV and P.PPRT.D_END
AND P.PPRTHS.C_CNTRY = 'US'
AND P.PPRTHS.C_PRE = P.PUSH.C_PRE
AND P.PPRT.C_SUFF = P.PUSH.C_SUFF
AND CURRENT DATE Between P.PUSH.D_EFFCTV and P.PUSH.D_END;

Please help me to get this
Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

First, ensure both your tables ('P.PPRT' and 'P.PUSH') are loaded into Power Query. This can be done by using the 'Source' step to connect to your data source and then navigating to the respective tables.
For both tables, you'll need to filter rows where the current date falls between 'D_EFFCTV' and 'D_END'.

PPRT_Filtered = Table.SelectRows(PPRT, each Date.From(DateTime.LocalNow()) >= [D_EFFCTV] and Date.From(DateTime.LocalNow()) <= [D_END])

Repeat a similar step for the 'P.PUSH' table.
Use the 'Table.Join' function to perform an inner join between the 'PPRT_Filtered' and 'PUSH_Filtered' tables on the 'C_PRE' and 'C_SUFF' columns.

JoinedTables = Table.Join(PPRT_Filtered, {"C_PRE", "C_SUFF"}, PUSH_Filtered, {"C_PRE", "C_SUFF"}, JoinKind.Inner)

After joining, filter the rows where 'C_CNTRY' equals 'US'. Assuming 'C_CNTRY' is in the 'PPRT' table:

FinalTable = Table.SelectRows(JoinedTables, each [C_CNTRY] = "US")

Finally, select the columns you need ('PART', 'P_COLM_1_', 'C_HARMZD_PRE', 'C_SUFF') from the 'FinalTable'.

ResultTable = Table.SelectColumns(FinalTable, {"PART", "P_COLM_1_", "C_HARMZD_PRE", "C_SUFF"})


Best Regards,
Dino Tao
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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

First, ensure both your tables ('P.PPRT' and 'P.PUSH') are loaded into Power Query. This can be done by using the 'Source' step to connect to your data source and then navigating to the respective tables.
For both tables, you'll need to filter rows where the current date falls between 'D_EFFCTV' and 'D_END'.

PPRT_Filtered = Table.SelectRows(PPRT, each Date.From(DateTime.LocalNow()) >= [D_EFFCTV] and Date.From(DateTime.LocalNow()) <= [D_END])

Repeat a similar step for the 'P.PUSH' table.
Use the 'Table.Join' function to perform an inner join between the 'PPRT_Filtered' and 'PUSH_Filtered' tables on the 'C_PRE' and 'C_SUFF' columns.

JoinedTables = Table.Join(PPRT_Filtered, {"C_PRE", "C_SUFF"}, PUSH_Filtered, {"C_PRE", "C_SUFF"}, JoinKind.Inner)

After joining, filter the rows where 'C_CNTRY' equals 'US'. Assuming 'C_CNTRY' is in the 'PPRT' table:

FinalTable = Table.SelectRows(JoinedTables, each [C_CNTRY] = "US")

Finally, select the columns you need ('PART', 'P_COLM_1_', 'C_HARMZD_PRE', 'C_SUFF') from the 'FinalTable'.

ResultTable = Table.SelectColumns(FinalTable, {"PART", "P_COLM_1_", "C_HARMZD_PRE", "C_SUFF"})


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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors