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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Same result when using switch formula

Hi Experts

 

I have the following switch formula to pull back the Top 10 Best performing product, but the switch formula keeps on giving me the same result for each product ...... i have check each of the individual measures and they all produce different values (end results)...

 

can see the error

 

Top Products Variance Gross Margin / Net Sales = 
VAR RankingContext = VALUES('Product'[Category])
VAR ProfitbabilityMeasure = SELECTEDVALUE(ProfitabilityMeasures[MeasureName])
VAR ReportingMeasure = SELECTEDVALUE(Reporting[Reporting])
RETURN

SWITCH(TRUE(),
    ProfitbabilityMeasure = "Gross Margin" && ReportingMeasure = "Reported"
       , CALCULATE( [GMvPY1% (Reported PY)]
            , TOPN(10, ALL('Product'[Category]),[GMvPY1% (Reported PY)])),
                     
    ProfitbabilityMeasure = "Gross Margin" && ReportingMeasure = "NOE"
       , CALCULATE( [GMvPY4% (NOE @ AOP Rate)]
            , TOPN(10, ALL('Product'[Category]),[GMvPY4% (NOE @ AOP Rate)])),
                    
    ProfitbabilityMeasure = "Gross Margin" 
       , CALCULATE( [GMvPY1% (Reported PY)]
            , TOPN(10, ALL('Product'[Category]),[GMvPY1% (Reported PY)])),
 
    ProfitbabilityMeasure = "Net Sales" && ReportingMeasure = "Reported"
       , CALCULATE( [NSvPY1% (Reported PY)]
            , TOPN(10, ALL('Product'[Category]),[NSvPY1% (Reported PY)])),
                     
    ProfitbabilityMeasure = "Net Sales" && ReportingMeasure = "NOE"
       , CALCULATE( [NSvPY4% (NOE @ AOP Rate)]
            , TOPN(10, ALL('Product'[Category]),[NSvPY4% (NOE @ AOP Rate)])),
                    
    ProfitbabilityMeasure = "Net Sales" 
       , CALCULATE( [NSvPY1% (Reported PY)]
            , TOPN(10, ALL('Product'[Category]),[NSvPY1% (Reported PY)])),
    RankingContext)        
1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Can you share the file or a dummy one, please? You can mask the sensitive parts first.

Did you make any selections? And only one selection of the two columns a time?

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Can you share the file or a dummy one, please? You can mask the sensitive parts first.

Did you make any selections? And only one selection of the two columns a time?

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Morning dale. i haved managed to solve the answer

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors