Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
hello, i have a table in which for each day i have the Sales % for each product, something like:
Date | Product | Sale for that day for that product | % Sale for that day for that product from total sales for that day|
I want to make a formula, in a column which return 3 values for each day, for each product, if the product sale Procent is in the top 70% the value should be tier1, is it is in the 70% from the last 30% from total it would say tier2 and blank for the rest
something like that.
Thank you
| day | product | sales that day | total sales that day | %from total | Tier |
| 01.01.2023 | Product05 | 30 | 116 | 0.25862069 | Tier1 |
| 01.01.2023 | Product07 | 27 | 116 | 0.232758621 | Tier1 |
| 01.01.2023 | Product01 | 11 | 116 | 0.094827586 | Tier1 |
| 01.01.2023 | Product09 | 11 | 116 | 0.094827586 | Tier1 |
| 01.01.2023 | Product10 | 9 | 116 | 0.077586207 | Tier2 |
| 01.01.2023 | Product11 | 7 | 116 | 0.060344828 | Tier2 |
| 01.01.2023 | Product08 | 5 | 116 | 0.043103448 | Tier2 |
| 01.01.2023 | Product03 | 5 | 116 | 0.043103448 | |
| 01.01.2023 | Product06 | 5 | 116 | 0.043103448 | |
| 01.01.2023 | Product04 | 4 | 116 | 0.034482759 | |
| 01.01.2023 | Product02 | 2 | 116 | 0.017241379 | |
| 01.02.2023 | Product04 | 20 | 84 | 0.238095238 | Tier1 |
| 01.02.2023 | Product08 | 18 | 84 | 0.214285714 | Tier1 |
| 01.02.2023 | Product10 | 14 | 84 | 0.166666667 | Tier1 |
| 01.02.2023 | Product11 | 6 | 84 | 0.071428571 | Tier1 |
| 01.02.2023 | Product09 | 5 | 84 | 0.05952381 | Tier2 |
| 01.02.2023 | Product02 | 5 | 84 | 0.05952381 | Tier2 |
| 01.02.2023 | Product01 | 5 | 84 | 0.05952381 | Tier2 |
| 01.02.2023 | Product05 | 4 | 84 | 0.047619048 | |
| 01.02.2023 | Product03 | 3 | 84 | 0.035714286 | |
| 01.02.2023 | Product06 | 3 | 84 | 0.035714286 | |
| 01.02.2023 | Product07 | 1 | 84 | 0.011904762 | |
| 01.03.2023 | Product08 | 26 | 129 | 0.201550388 | Tier1 |
| 01.03.2023 | Product06 | 25 | 129 | 0.19379845 | Tier1 |
| 01.03.2023 | Product09 | 14 | 129 | 0.108527132 | Tier1 |
| 01.03.2023 | Product11 | 12 | 129 | 0.093023256 | Tier1 |
| 01.03.2023 | Product01 | 12 | 129 | 0.093023256 | Tier1 |
| 01.03.2023 | Product05 | 11 | 129 | 0.085271318 | Tier2 |
| 01.03.2023 | Product10 | 11 | 129 | 0.085271318 | Tier2 |
| 01.03.2023 | Product02 | 9 | 129 | 0.069767442 | |
| 01.03.2023 | Product04 | 5 | 129 | 0.03875969 | |
| 01.03.2023 | Product03 | 3 | 129 | 0.023255814 | |
| 01.03.2023 | Product07 | 1 | 129 | 0.007751938 |
Solved! Go to Solution.
Hi @cristianj ,
I created a sample pbix file(see the attachment), please find the details in it.
By measures:
rank =
VAR _seldate =
SELECTEDVALUE ( 'Table'[day] )
RETURN
RANKX (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ),
CALCULATE ( MAX ( 'Table'[%from total] ) ),
,
DESC,
DENSE
)Tier =
VAR _seldate =
SELECTEDVALUE ( 'Table'[day] )
VAR _maxrank =
MAXX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ), [rank] )
VAR _70perrank =
ROUND ( _maxrank * 0.7, 0 )
RETURN
IF (
[rank] <= _70perrank,
IF ( [rank] <= _70perrank * 0.7, "Tier1", "Tier2" ),
BLANK ()
)
By calculated columns:
Column =
RANKX (
FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ),
'Table'[%from total],
,
DESC,
DENSE
)Column 2 =
VAR _maxrank =
MAXX ( FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ), [Column] )
VAR _70perrank =
ROUND ( _maxrank * 0.7, 0 )
RETURN
IF (
[Column] <= _70perrank,
IF ( [Column] <= _70perrank * 0.7, "Tier1", "Tier2" ),
BLANK ()
)
Best Regards
Hi @cristianj ,
I created a sample pbix file(see the attachment), please find the details in it.
By measures:
rank =
VAR _seldate =
SELECTEDVALUE ( 'Table'[day] )
RETURN
RANKX (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ),
CALCULATE ( MAX ( 'Table'[%from total] ) ),
,
DESC,
DENSE
)Tier =
VAR _seldate =
SELECTEDVALUE ( 'Table'[day] )
VAR _maxrank =
MAXX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[day] = _seldate ), [rank] )
VAR _70perrank =
ROUND ( _maxrank * 0.7, 0 )
RETURN
IF (
[rank] <= _70perrank,
IF ( [rank] <= _70perrank * 0.7, "Tier1", "Tier2" ),
BLANK ()
)
By calculated columns:
Column =
RANKX (
FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ),
'Table'[%from total],
,
DESC,
DENSE
)Column 2 =
VAR _maxrank =
MAXX ( FILTER ( 'Table', 'Table'[day] = EARLIER ( 'Table'[day] ) ), [Column] )
VAR _70perrank =
ROUND ( _maxrank * 0.7, 0 )
RETURN
IF (
[Column] <= _70perrank,
IF ( [Column] <= _70perrank * 0.7, "Tier1", "Tier2" ),
BLANK ()
)
Best Regards
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 46 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 67 | |
| 31 | |
| 27 | |
| 24 |