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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
mmvohra
Helper II
Helper II

Need help regarding fine measure formulation

I want to make measure as per the following logic:
Filter table → only rows where [Dif KM_1] <= ParameterValue.

Within each Consolidated ID:

Find minimum date.
Find the immediate date after the minimum date which consecutive date

Get price at min date.

Get price at consecutive date.


Compute difference (min date – consecutive date.).

Sum the difference for all consolidated ID.

Basically it should find the consecutive difference in price within same Consolidated ID and then sums those difference for all ConsolidatedID.

URL of file
File URL sample pbix 

1 ACCEPTED SOLUTION

Hi,

Check now

Ashish_Mathur_0-1771458112746.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

14 REPLIES 14
v-karpurapud
Community Support
Community Support

Hi @mmvohra 

We have not received a response from you regarding the query and were following up to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

 

Thank You.

v-karpurapud
Community Support
Community Support

Hi @mmvohra 

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @Irwan , @Ashish_Mathur  and @danextian  for sharing valuable insights.

 

Could you please confirm if your query has been resolved by the provided solution?If you have any more questions, please let us know and we’ll be happy to help.

Regards,

Microsoft Fabric Community Support Team.

danextian
Super User
Super User

Hi @mmvohra 

Please post your expected  result as well given the same sample data. If this were in Excel, how would you compute this?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

Cannot understand your question.  Please show the expected result very clearly.  Also, there is no Dif KM_1 column in the table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

The answer should be 20000.  I think the formula in cell I7 is wrong - it should be =[@Price]-$E$6.  PBI file attached.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I want table to be dynamically filtered based on parameter value and once the table is dynamically filtered only then it can sum up the difference between consecutive for each consolidatedID

Hi,

Check now

Ashish_Mathur_0-1771458112746.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Irwan
Super User
Super User

hello @mmvohra 

 

the file in the link seems to be missing.

Thank you.

File URL is updated, it contains power bi file and excel file telling what I want.
https://drive.google.com/drive/folders/1gKyH3VLKGp7rJ58o4f10TIHXP6wh2mWz?usp=sharing 

mmvohra_0-1771312058759.png


Do let me know if there is any further query

hello @mmvohra 

 

you can do this in various ways, but here i show how i usually do.

you can do this in either calculated column or measure.

1. using calculated column

- create a new table to summarize those ID less than 3000.

Irwan_0-1771381243810.png

Summarize =
SUMMARIZE(
    FILTER(
        'Work',
        'Work'[Dif KM_1]=0||'Work'[Dif KM_1]<=2000
    ),
    'Work'[ID],
    'Work'[ConsolidatedID],
    'Work'[Distance (km)],
    'Work'[Date],
    'Work'[Price],
    'Work'[Person Type],
    'Work'[Name],
    'Work'[Link]
)
- create a new calculated column with following DAX for price different.
Irwan_1-1771381316795.png

 

Price Different =
var _Previous =
MAXX(
    FILTER(
        'Summarize',
        'Summarize'[ConsolidatedID]=EARLIER('Summarize'[ConsolidatedID])&&
        'Summarize'[Date]<EARLIER('Summarize'[Date])
    ),
    'Summarize'[Price]
)
Return
IF(
    not ISBLANK(_Previous),
    'Summarize'[Price]-_Previous
)
 - create a new measure for sum value of price different.
Sum Column = SUM('Summarize'[Price Different])
Irwan_2-1771381371616.png

 

2. using measure

- create a new measure with following DAX for calculating price different.

Price Different =
var _Previous =
MAXX(
    FILTER(
        ALL('Work'),
        'Work'[ConsolidatedID]=SELECTEDVALUE('Work'[ConsolidatedID])&&
        'Work'[Date]<SELECTEDVALUE('Work'[Date])&&
        'Work'[Dif KM_1]<=2000
    ),
    'Work'[Price]
)
Return
IF(
    not ISBLANK(_Previous),
    SELECTEDVALUE('Work'[Price])-_Previous
)
- create a new measure with following DAX for sum value.
Sum Measure =
SUMX(
    FILTER(
        ALL('Work'),
        'Work'[ConsolidatedID]=SELECTEDVALUE('Work'[ConsolidatedID])&&
        'Work'[Dif KM_1]<=3000
    ),
    [Price Different]
)
- create a slicer for consolidateID filter and KPI visual for showing sum value (either card or KPI or any visual you want)
Irwan_6-1771381830018.png

 

Hope this will help.

Thank you.

I want total sum but it should be dynamic based on the value of parameter. 
Calculated columns and table are of no use as parameter does not work on them.
I want a measure that can dynamically filter the table based on dif KM_1<=parameter value condition and then find the sum of difference in price meeting the criteria.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.