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
Whitewater100
Solution Sage
Solution Sage

M code Substitute Question

Hello:

 

I have a need to show start of week as Monday's Date unless Monday is a holiday, then Tuesday's Date would be the Start of Week Date.

 

I also have another measure in DAX showing the previous weeks date with the same criteria. I'll put the measures below.

 

What appears to be happening is that these two measures(in cards) go blank when viewing the report in Power BI Service.

 

I'm wondeing if replicating these measures in M code in a Date table would fix the blank visuals in Service?

 

Thanks for any input on this issue!

 

Report Start Date =
var _selectedYear = SELECTEDVALUE(Dates1[year])
var _selectedWeek = SELECTEDVALUE(Dates1[Week No.])
var _startOfTheWeek =
CALCULATE(
    FIRSTDATE(Dates1[Date]),
    FILTER(ALL(Dates1),
    Dates1[Week No.] = _selectedWeek && Dates1[year] = _selectedYear && Dates1[Flag] = "WeekStart")
)
return
_startOfTheWeek
 
PW Report Start Date =
var _selectedYear = SELECTEDVALUE(Dates1[year])
var _selectedWeek = SELECTEDVALUE(Dates1[Week No.])-1
var _startOfTheWeek =
CALCULATE(
    FIRSTDATE(Dates1[Date]),
    FILTER(ALL(Dates1),
    Dates1[Week No.] = _selectedWeek && Dates1[year] = _selectedYear && Dates1[Flag] = "WeekStart")
)
return
_startOfTheWeek
1 REPLY 1
Anonymous
Not applicable

Hi @Whitewater100 ,

 

In Power Query, M language is used. DAX is used in Power BI Desktop. M and DAX are two completely different languages.

So you can't just copy the dax formula into the M code.

Power Query, M, and DAX: A happy threesome.

 

 

Best Regards,

Stephen 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