Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
wendereis
Helper I
Helper I

How to do DAX Formula RankX with Filter in Power Query Custom

Hi guys!
I need your help so much, please!

I have the DAX formula below and I need to do something similar this in Power Query "Custom Column". How can I write a formula there that bring me the same DAX result? I don't know how to do a syntax formula in Power Query translate the DAX formula below to Power Query formula when create a Custom Column.

Rank = RANKX(FILTER(Calendar_Today_Date, Calendar_Today_Date[IsBusinessDay] = "Yes"), Calendar_Today_Date[Date],,ASC)
1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @wendereis - In Power Query editor, IsBusinessDay i have filtered with "Yes" category and sorted the date column with ASC after that added the index column starts from 1.

 

M code FYR:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtE1MNc1MFTSUYpMLVaK1UESNAIK+uWjihljU2iCTdAUi24zbArNsSi0gCmMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, IsBusinessDay = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"IsBusinessDay", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([IsBusinessDay] = "Yes")),
#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Date", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type)
in
#"Added Index"

 

rajendraongole1_0-1720975252153.png

 

Hope it helps 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
rajendraongole1
Super User
Super User

Hi @wendereis - In Power Query editor, IsBusinessDay i have filtered with "Yes" category and sorted the date column with ASC after that added the index column starts from 1.

 

M code FYR:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtE1MNc1MFTSUYpMLVaK1UESNAIK+uWjihljU2iCTdAUi24zbArNsSi0gCmMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, IsBusinessDay = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"IsBusinessDay", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([IsBusinessDay] = "Yes")),
#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Date", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type)
in
#"Added Index"

 

rajendraongole1_0-1720975252153.png

 

Hope it helps 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you so much my friend!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.