Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I cannot figure out how to convert the following DAX to M code. I need to get the count of each Weekday by Month
11/2022 Sunday 4
11/2022 Monday 4
11/2022 Tuesday 5
etc.
=VAR MonthYear = Dates[MonthnYear]
VAR __Weekday = Dates[Day of Week]
return
CALCULATE(
COUNTROWS (Dates),
FILTER ( Dates,
Dates[MonthnYear] = MonthYear
&& Dates[Day of Week] = __Weekday
) )
Solved! Go to Solution.
Hi @sandy2786 ,
According to your description, I create a sample. Based on the code you provided I create a calculated column and get the following result:
If you want to do it in M language, here's my solution. Create a custom column.
Table.RowCount(Table.SelectRows(#"Changed Type",(x)=>x[MonthnYear]=[MonthnYear]and x[Day of Week]=[Day of Week]))
Get the same result:
In addition, if you just want to show the result in a visual, you can simply put Date column in the visual and select Count without other calculation.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @sandy2786 ,
According to your description, I create a sample. Based on the code you provided I create a calculated column and get the following result:
If you want to do it in M language, here's my solution. Create a custom column.
Table.RowCount(Table.SelectRows(#"Changed Type",(x)=>x[MonthnYear]=[MonthnYear]and x[Day of Week]=[Day of Week]))
Get the same result:
In addition, if you just want to show the result in a visual, you can simply put Date column in the visual and select Count without other calculation.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dont use DAx for date logic, use calendar table.
Build a good calamndar tabnbel onace and use it always.
Click here to learn about Power Bi calendar tables
You can quickly do it like this
Click Modelling and New Table
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 35 | |
| 34 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 136 | |
| 102 | |
| 68 | |
| 66 | |
| 58 |