Forum Discussion
Measure to Calculate Objective
- Anonymous2 years ago
Hi, RedaBi
Thank you very much for your reply. First, I've created a calculated column in the sales table to find the month of the current date as follows:
At this point, put the month column and the Distrbuteur, YEAR column in the objectif table into the table visual:
I created a Sum CA measure using the following DAX expression:
Sum CA = VAR _cd_dist = SELECTEDVALUE ( objectif[Distrbuteur] ) RETURN CALCULATE ( SUM ( 'sales'[CA] ), TREATAS ( SELECTCOLUMNS ( 'objectif', "cd dist", 'objectif'[Distrbuteur] ), sales[Cd Dist] ), 'sales'[Cd Dist] = _cd_dist )Note that there is no relationship established between my two tables:
I created a PALIER measure using the following DAX expression:
PALIER = VAR _current_month = SELECTEDVALUE ( 'sales'[Month] ) VAR _current_palier1 = CALCULATE ( MAX ( 'objectif'[PALIER 1] ), 'objectif'[MONTH] = _current_month ) VAR _current_palier2 = CALCULATE ( MAX ( 'objectif'[PALIER 2] ), 'objectif'[MONTH] = _current_month ) VAR _current_palier3 = CALCULATE ( MAX ( 'objectif'[PALIER 3] ), 'objectif'[MONTH] = _current_month ) VAR _current_palier4 = CALCULATE ( MAX ( 'objectif'[PALIER 4] ), 'objectif'[MONTH] = _current_month ) VAR _current_palier5 = CALCULATE ( MAX ( 'objectif'[PALIER 5] ), 'objectif'[MONTH] = _current_month ) RETURN IF ( [Sum CA] <> BLANK () && _current_month = CALCULATE ( MAX ( 'objectif'[MONTH] ), 'objectif'[MONTH] = _current_month ), SWITCH ( TRUE (), [Sum CA] >= _current_palier5, "PALIER 5", [Sum CA] >= _current_palier4 && [Sum CA] < _current_palier5, "PALIER 4", [Sum CA] >= _current_palier3 && [Sum CA] < _current_palier4, "PALIER 3", [Sum CA] >= _current_palier2 && [Sum CA] < _current_palier3, "PALIER 2", [Sum CA] >= _current_palier1 && [Sum CA] < _current_palier2, "PALIER 1" ) )Put these two measures into the table visual:
In the example you gave, D11 has a Sum CA of 1,000,000 in March 2024. Sum CA = 82000000 + 138719422 + 145000000 = 365719422 in January 2024.
Since in March 2024, the Sum CA of D11 is 1000000, according to the conditions you gave, it does not meet any of the grades in the objectif table, as shown in the figure below,
I've provided the PBIX file used this time below.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
- RedaBi2 years agoFrequent Visitor
Good evening, okay, I understand. I will be more careful in my future posts.