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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors