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
Anonymous
Not applicable

Measure inside a calculated column does not respect the filter

Hi All,

 

I new to power bi so please bear with me in my query.

I have the data similar to below, what i need is the commonsales is divided as per ratio to sales, but this should be month wise.

So for this I created a measure as ratio=CALCULATE(DIVIDE(SUM(Table[Sales],Table[Commonsales]))*100, Allselected(Table, Table[Date])) This works fine but when i use it in calculation in the "Required Column" as:

Sales + Sales * ratio 

It does not respect the filter. I understand columns are precalculated and that is why this happens.

But the problem is i cannot use measure for "required column" becuase both sales and commonsales are calculated column. So it seems like a deadlock 🙂 

DepartmentDateSalesCommonsalesRequired Column
xyx1-Jul-2210020
xyz10-Jul-220100
abc1-Aug-2210015
abx10-Aug-220100
vvv15-Aug-2210015

 

Any help in this regard will be highly appreciated.

 

Thanks

Anuj Priyadarshi

1 ACCEPTED SOLUTION

@Anonymous 
Here is a sample file with the solution https://www.dropbox.com/t/ZUwnQDxjU6jCf260

You need first to create a Month-Year column that will be required in the calculation. Then create the required column measure as follows

Required Column = 
VAR CurrentSales = SUM ( 'Table'[Sales] )
VAR CurrentMonthTable = CALCULATETABLE ( 'Table', REMOVEFILTERS ( 'Table' ), VALUES ( 'Table'[Month-Year] ) )
VAR TotalCommonSales = SUMX ( CurrentMonthTable, 'Table'[Commonsales] )
VAR DatesWithSales = COUNTROWS ( FILTER ( CurrentMonthTable, 'Table'[Sales] > 0 ) )
VAR Ratio = DIVIDE ( CurrentSales, TotalCommonSales * DatesWithSales )
RETURN
    CurrentSales * ( 1 + Ratio )

View solution in original post

5 REPLIES 5
saravanan_p
Resolver III
Resolver III

The measure you mentioned as ratio isnt working first of all. Post the desired result so that we could help you 

amitchandak
Super User
Super User

@Anonymous , Please check the update from @tamerj1 

 

A calculated column will not table slicer filter , so you have to create a meausre only

 

Try like

 

sumx(Table, [Sales] + [Sales] * [ratio]) 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
tamerj1
Super User
Super User

Hi @Anonymous 
Why the result for xyx is 20 not 15?

Anonymous
Not applicable

Because in jul there is only one sale and cone common sales, so the whole the cmmonsaale is considered in xyx. 

@Anonymous 
Here is a sample file with the solution https://www.dropbox.com/t/ZUwnQDxjU6jCf260

You need first to create a Month-Year column that will be required in the calculation. Then create the required column measure as follows

Required Column = 
VAR CurrentSales = SUM ( 'Table'[Sales] )
VAR CurrentMonthTable = CALCULATETABLE ( 'Table', REMOVEFILTERS ( 'Table' ), VALUES ( 'Table'[Month-Year] ) )
VAR TotalCommonSales = SUMX ( CurrentMonthTable, 'Table'[Commonsales] )
VAR DatesWithSales = COUNTROWS ( FILTER ( CurrentMonthTable, 'Table'[Sales] > 0 ) )
VAR Ratio = DIVIDE ( CurrentSales, TotalCommonSales * DatesWithSales )
RETURN
    CurrentSales * ( 1 + Ratio )

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.

Jan NL Carousel

Fabric Community Update - January 2025

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