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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Function based on filter and columns on a same table

Hello everyone, 

 

I'm new user of Power BI and Dax. I'm writting to you because of a problem I can't achieve to solve. 

 

I have a table with all my data and particularly those variables : Cycle, Country, average amount, mix effect. 

I would like to put a filter in order the user can select two cycles. I created a numerical equivalent of cycle in order to get the filtered value dynamically.

 

Once those two cycles are selected, for each country, I would like to calculate the difference of the country amount with the total amount (Find below the values for the difference) : 

First_issue.png

 

Then, For each country, I would like to calculate the difference between amount of cycle 1 and amount of cycle 2 : 

SECOND_issue.png

I tried this in order to achieve the first statement : 

Unitary_Mix:= 
    VAR MaxCycle = CALCULATE (VALUES(RESULT[Cycle]);FILTER(ALL(RESULT[Cycle_num]); RESULT[Cycle_num] = MAX(RESULT[Cycle_num])))
    VAR MinCycle = CALCULATE (VALUES(RESULT[Cycle]);FILTER(ALL(RESULT[Cycle_num]); RESULT[Cycle_num] = MIN(RESULT[Cycle_num])))
 
    Return CALCULATE(RESULT[av_EI_nedc_sales_filtered]; FILTER(RESULT;[Cycle] = MinCycle)) -  CALCULATE(SUM(RESULT[av_EI_nedc_sales_filtered]); RESULT[Cycle] = MaxCycle)

But it doesn't work. Can someone help me about this please ? 

 

Thank you in advance for your answers. 

Regards

 

 

1 ACCEPTED SOLUTION
Cmcmahan
Resident Rockstar
Resident Rockstar

I'm not sure exactly what you're asking for here. Your [Unitary_Mix] measure looks like it should work. What incorrect results are you seeing, and what are the expected results?

In the first example, would you want to display 2.7 in the row instead of 102.2? Or would you want to display both 102.2 and 2.7 values next to each other in the matrix?

 

For the second example, do you want the total column to be the difference between the other two?  Or do you want the second column to be the difference from the first column?  Do you want this as another sub-column?  

 

I'm assuming each entry is an aggregated average, but I can't tell much more than that.  Is it possible for you to share your data with us?  Even a smaller subset of anonymized data with desired output values would be very helpful here. The ability to copy paste your data makes it much easier to develop prototypes. 

View solution in original post

1 REPLY 1
Cmcmahan
Resident Rockstar
Resident Rockstar

I'm not sure exactly what you're asking for here. Your [Unitary_Mix] measure looks like it should work. What incorrect results are you seeing, and what are the expected results?

In the first example, would you want to display 2.7 in the row instead of 102.2? Or would you want to display both 102.2 and 2.7 values next to each other in the matrix?

 

For the second example, do you want the total column to be the difference between the other two?  Or do you want the second column to be the difference from the first column?  Do you want this as another sub-column?  

 

I'm assuming each entry is an aggregated average, but I can't tell much more than that.  Is it possible for you to share your data with us?  Even a smaller subset of anonymized data with desired output values would be very helpful here. The ability to copy paste your data makes it much easier to develop prototypes. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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