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

Cube.ApplyParameter selection current week and last week

 

For the week selection I have found in the community forum this solution

(dDate as date) =>
let
    Quelle = if
Number.RoundDown((Date.DayOfYear(dDate )-(Date.DayOfWeek(dDate , Day.Monday)+1)+10)/7)=0
 
then 
Number.ToText(Date.Year(dDate)-1)& Text.End("0" & Number.ToText(Number.RoundDown((Date.DayOfYear(#date(Date.Year(dDate )-1,12,31))-(Date.DayOfWeek(#date(Date.Year(dDate )-1,12,31), Day.Monday)+1)+10)/7)),2)
 
else if
(Number.RoundDown((Date.DayOfYear(dDate )-(Date.DayOfWeek(dDate , Day.Monday)+1)+10)/7)=53
and (Date.DayOfWeek(#date(Date.Year(dDate ),12,31), Day.Monday)+1<4))
 
then
Number.ToText(Date.Year(dDate)+1)&"01"
 
else 
Number.ToText(Date.Year(dDate))& Text.End("0"&Number.ToText(Number.RoundDown((Date.DayOfYear(dDate)-(Date.DayOfWeek(dDate, Day.Monday)+1)+10)/7)),2)
in
    Quelle

 and had to save this in a new quary as DateToYYYYWW and had to add in my original quary this one

 

let
CurrentYYYYWW= DateToYYYYWW(Date.From(DateTime.LocalNow())),
NextWeek = DateToYYYYWW(Date.AddDays(Date.From(DateTime.LocalNow()),7))
in NextWeek

 

let
Source = SapBusinessWarehouse.Cubes("E9Esap.nestle.com", "E9E", "102", "USERS", [Implementation="2.0", LanguageCode="EN"]),
Y6DS1MC0 = Source{[Name="Y6DS1MC0"]}[Data],
#"Y6DS1MC0/Y6DS1MC0Q_001" = Y6DS1MC0{[Id="Y6DS1MC0/Y6DS1MC0Q_001"]}[Data],
#"Added Items" = Cube.Transform(#"Y6DS1MC0/Y6DS1MC0Q_001",
CurrentYYYYWW= DateToYYYYWW(Date.From(DateTime.LocalNow())),
{
{Cube.ApplyParameter, "[YMMPAREA]", {{"[YPLGAREA].[D]"}}},
{Cube.ApplyParameter, "[YPMUNIT]", {"[YUNITS].[PUM]"}},
{Cube.ApplyParameter, "[YSOCLMTH]", {{}}},
{Cube.ApplyParameter, "[YSALESOR]", {{"[0SALESORG].[NL10]"}}},
{Cube.ApplyParameter, "[YSNPCPH2]", {{"[YMAT_COMP__0PRODH2].[NLK]"}}},

 

But I get this message.

 

Expression.Error: The name 'CurrentYYYYWW' wasn't recognized. Make sure it's spelled correctly.

 

Does anyone knows how to solve this?

 

1 REPLY 1
lbendlin
Super User
Super User

Your Cube.Transform call is not in the right format.

 

Cube.Transform - PowerQuery M | Microsoft Learn

 

You may want to clear out the sensitive information from your examples.

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.