Forum Discussion
Convert Power M query to snowflake view
- 11 months ago
v-dineshya Hey , sorry for late response.
Yeah i got my collegue help to fix this internally.
DineshArivu what I understood from you PQ code that you are spliting SERVICEPERIOD into Service Period From/To dates, but later discards them.
You filters rows to only those where SCHEDULEID contains "MRR" and builds a key MergeWID_InvoiceDate = CUSTOMERID + invoice month-year (from INVOICECREATEDDATE, formatted MMM-yy).
Then you removes the duplicates and groups by that key and creates 2 lists seperated by a comma : 1st InsertedCreatedDate the group invoice dates and 2nd InvoiceCreatedBy the list of distinct creators.
This is how I imagine the query :
create or replace view DATALAKE.DM_BSS_OSS.VW_MRR_INVOICE_CREATED as
with base as (
select
CUSTOMERID,
cast(INVOICECREATEDDATE as date) as INVOICECREATEDDATE,
INVOICECREATEDBY,
SCHEDULEID
from DATALAKE.DM_BSS_OSS.VW_WD_INVOICE_WITHPRODUCTHIERARCHY
where SCHEDULEID ilike '%MRR%'
),
dedup as (
select distinct
(CUSTOMERID || to_char(INVOICECREATEDDATE, 'Mon-YY')) as MERGEWID_INVOICEDATE,
INVOICECREATEDDATE,
INVOICECREATEDBY
from base
)
select
MERGEWID_INVOICEDATE,
listagg(to_char(INVOICECREATEDDATE, 'Mon-DD-YYYY'), ',')
within group (order by INVOICECREATEDDATE asc) as INSERTEDCREATEDDATE,
listagg(distinct trim(INVOICECREATEDBY), ', ') as INVOICECREATEDBY
from dedup
group by MERGEWID_INVOICEDATE
Hi DineshArivu ,
Could you please try the proposed solution shared by AmiraBedh . Please do let us know if you have any further queries.
Regards,
Dinesh
- v-dineshya11 months agoCommunity Support
Hi DineshArivu ,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.
Regards,
Dinesh
- DineshArivu11 months agoHelper I
v-dineshya Hey , sorry for late response.
Yeah i got my collegue help to fix this internally.
- v-dineshya11 months agoCommunity Support
Hi DineshArivu ,
Thank you for the update. We are pleased to hear that you have found a workaround. Please share the details here, to assist others with similar issues in community. Please do let us know if you have any further queries.
Regards,
Dinesh