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.
Hi all,
I am trying to do a monthly calculation (summing up every day's value) to calculate the comission for a rep .
Date | Account Rep |
9/1/20 | steve |
9/1/20 | Austin |
9/1/20 | Mercer |
9/1/20 | Justin |
9/2/20 | Austin |
9/2/20 | Mercer |
9/3/20 | Steve |
9/3/20 | Mercer |
9/3/20 | Austin |
9/3/20 | Justin |
For the above and a daily calculation i do a distinct count on the reps and multiple each rep with thier commission value ex: 9/1 - for steve it is 1*20 ,
for austin it is 1*15 etc
and then sum them all up the net-day commission.
The problem is when i do monthly. Because the distinct is making the Sep count as 1*20 + 1*15 etc... And i am supposed to have it as adding up the commission per day for the entire month.
* the reason i have the distinct is because steve can have multiple rows in the table for the same day due to an order being on hold or cancelled etc. The rule is, if they are on the table for that day, they get the commission.
Any recommendation on how to get a monthly count instead of a daily count when displaying results on a monthly visual.
Solved! Go to Solution.
Hi @PBI5851,
So you mean the target is the record count based on date and person(not consider the order status) and the real amount is 'unclosed' records count and multiply based on the corresponding person's rate, right?
If this is a case, you can try to use the following measure formulas:
Plan =
CALCULATE (
COUNT ( T1[JobID] ),
ALLSELECTED ( T1 ),
VALUES ( T1[CommDate] ),
VALUES ( T1[Name] )
)
Real =
VAR summary =
SUMMARIZE (
T1,
[CommDate],
[Name],
"Real",
CALCULATE (
COUNT ( T1[JobID] ),
FILTER ( ALLSELECTED ( T1 ), [OrdStatus] <> "Close" ),
VALUES ( T1[CommDate] ),
VALUES ( T1[Name] )
)
* LOOKUPVALUE ( Person[Rate], Person[Person], T1[Name] )
)
RETURN
SUMX ( summary, [Real] + 0 )
Regards,
Xiaoxin Sheng
Hi, @PBI5851 , as insufficient info on your data model was provided, I tweak one of my former projects which appears similar to your description.
The simplified data model is as follows,
Based on it, a matrix is created
You may want to refer to a dummy file for more details.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@CNENFRNL i agree i didnt provide clear information. I'll try explaining it a bit differently.
CommDate | Name | OrdStatus | JobID |
1/1/2010 | Steve | Ship | J123 |
1/1/2010 | Jake | Close | J124 |
1/1/2010 | Monica | Close | J125 |
1/1/2010 | Austin | Process | J126 |
1/1/2010 | Steve | Close | J127 |
1/1/2010 | Jake | Ship | J128 |
1/2/2010 | Jake | Close | J129 |
1/2/2010 | Jacob | Process | J130 |
1/2/2010 | Steve | Close | J131 |
1/2/2010 | Monica | Ship | J132 |
1/2/2010 | Jake | Close | J133 |
2/2/2010 | Amy | Ship | J134 |
2/2/2010 | Amy | Close | J135 |
2/2/2010 | Steve | Close | J136 |
2/2/2010 | Austin | Close | J137 |
2/5/2010 | John | Process | J138 |
2/5/2010 | Austin | Process | J139 |
2/5/2010 | Steve | Close | J140 |
2/5/2010 | Mary | Ship | J141 |
2/5/2010 | Jake | Close | J142 |
2/5/2010 | Jake | Ship | J143 |
The below info is inidividual's criteria, not part of any table
Amy | 2 |
Monica | 2 |
Steve | 5 |
Jacob | 2 |
Mary | 5 |
So if the above person has an order for a day, their target is to make sure it is 1* the above number. If they are active for that day, it is 1*the above number, irrespective of how many orders are placed. Using above data, i need to provide two visuals, a Day and a Monthly visual. Default being 3 i.e for Austin and other it is 1*3
Day Visual
Day | OrdersPlaced | Target |
1/1/2010 | 6 | 13 |
1/2/2010 | 5 | 12 |
2/1/2010 | 4 | 10 |
2/5/2010 | 6 | 10 |
Monthly Visual
Year | Month | OrderPlaced | target |
2010 | Jan | 11 | 25 |
2010 | Feb | 10 | 20 |
To explain the Target for 1/1/10. Total Orders placed were 6. But the individuals who placed an Order on 1/1 were Austin (1*3), Jake (1*3), Monica (1*2) and Steve (1*5), which brings my Target to 13.
For Data Model - I have a date table connected to Job via the Date - CommDate
Hope this helps. I am getting the Day Visual , but the Monthly visual is incorrect.
TMOrderPlaced = CALCULATE(COUNTA(CommDetail[JobID]), USERELATIONSHIP(Datetable[Date], CommDetail[CommDate])))
TMOrderTarget =
Hi @PBI5851,
So you mean the target is the record count based on date and person(not consider the order status) and the real amount is 'unclosed' records count and multiply based on the corresponding person's rate, right?
If this is a case, you can try to use the following measure formulas:
Plan =
CALCULATE (
COUNT ( T1[JobID] ),
ALLSELECTED ( T1 ),
VALUES ( T1[CommDate] ),
VALUES ( T1[Name] )
)
Real =
VAR summary =
SUMMARIZE (
T1,
[CommDate],
[Name],
"Real",
CALCULATE (
COUNT ( T1[JobID] ),
FILTER ( ALLSELECTED ( T1 ), [OrdStatus] <> "Close" ),
VALUES ( T1[CommDate] ),
VALUES ( T1[Name] )
)
* LOOKUPVALUE ( Person[Rate], Person[Person], T1[Name] )
)
RETURN
SUMX ( summary, [Real] + 0 )
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |