How to Use a Dynamic Named Range Variable in Power Query Table.PIvot Function for Automation

26 Views Asked by At

I have a workbook that is linked to many other workbooks through PQ and I wanted to update the data I pull from these external workbooks based on a dynamic named range.

I have called the named range 'QtrDate'. Is it possible to update the M code in PQ to incorporate the named range 'QtrDate' into the following;

= Table.Pivot(#"Sorted Rows", List.Distinct(#"Sorted Rows"[Deal]), "Deal", "12/31/2023")

I want the column name 12/31/2023 to now = QtrDate and the List.Sum to = QtrDate.

The QtrDate named range in this instance is = 12/31/2023

I tried replacing {"9/30/2023",... with QtrDate but PQ gives the following error:

Expression.Error: We cannot convert the value #date(2023, 12, 31) to type Text. Details: Value=12/31/2023 Type=[Type]

0

There are 0 best solutions below