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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
parthiv_22
New Member

Compare value of calculated column vs normal column

I have a calculated date column (lets call in X) in my table. I have another normal date column (Y) in my table. I am not able to compare if Y is less than X since X is a calculated column. Any help on what I can do to solve this is appreciated. 

 

parthiv_22_0-1694768724246.png

 

1 REPLY 1
123abc
Community Champion
Community Champion

If you have a calculated date column (X) and a normal date column (Y) in your table, you can compare them using DAX in Power BI. You can create a new measure or column to perform this comparison. Here's how you can do it:

  1. Create a New Measure: If you want to create a measure that calculates a result for each row in your visualizations, you can use a DAX measure. In this example, I'll call the measure "ComparisonResult."

ComparisonResult = IF(YourTable[Y] < YourTable[X], "Y is less than X", "Y is greater than or equal to X")

 

  1. Replace "YourTable" with the actual name of your table, and "X" and "Y" with the names of your calculated and normal date columns, respectively. This measure will return a text result indicating whether Y is less than X or not.

  2. Create a New Calculated Column: If you want to create a new column in your table that permanently stores the comparison result, you can create a calculated column using DAX. In this case, you'll use the ADDCOLUMNS function to iterate through the rows and perform the comparison.

NewColumn =
ADDCOLUMNS(
YourTable,
"ComparisonResult",
IF([Y] < [X], "Y is less than X", "Y is greater than or equal to X")
)

 

  1. This DAX formula adds a new column called "ComparisonResult" to your table, which will contain the comparison result for each row.

After creating either the measure or the calculated column, you can use it in your visualizations to see the comparison between the Y and X columns. If Y is less than X, the result will indicate that, and if not, it will show the opposite.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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