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! Request now

Reply
ktt777
Helper V
Helper V

Variable calculation

hi, 

 

Here is my raw data: 

 

FruitMonthSale
AppleJanuary9
OrangeJanuary16
AppleFebruary22
OrangeFebruary45
AppleMarch23
OrangeMarch16

I want to calculate the total sale based on the target as below :

Fruit LowMediumMax
Apple0-1010-20more than 20
Orange0-1515-25More than 25

 the final result should show the total sale within each target:

FruitLowMediumMax
Apple9045
Orange03245

 

How can i make it dynamtic in dax fomular so i can change the target and add more fruit type

 

thanks, 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@ktt777 , Create a new column like the below in you table and use in as column in Matrix

 

If([Fruit] ="Apple",
Switch ( True(),
[Sale] <=10 , "Low",
[Sales] <=20, "Medium",
"Max"
),
Switch ( True(),
[Sale] <=15 , "Low",
[Sales] <=25, "Medium",
"Max"
)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

PhilipTreacy
Super User
Super User

Hi @ktt777 

 

Download sample PBIX file

 

Create 3 measures like so

 

 

Low = CALCULATE(SUM('Table1'[Sale]), FILTER('Table1', 'Table1'[Fruit] = SELECTEDVALUE('Table1'[Fruit]) && 'Table1'[Sale] < 10 ))
Medium = CALCULATE(SUM('Table1'[Sale]), FILTER('Table1', 'Table1'[Fruit] = SELECTEDVALUE('Table1'[Fruit]) && 'Table1'[Sale] >= 10 && 'Table1'[Sale] < 20 ))
Max = CALCULATE(SUM('Table1'[Sale]), FILTER('Table1', 'Table1'[Fruit] = SELECTEDVALUE('Table1'[Fruit]) && 'Table1'[Sale] >= 20 ))

 

 

 

Add these to a Table visual

frtab.png

If you add more fruit the measures will work for them

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @ktt777 

 

Download sample PBIX file

 

Create 3 measures like so

 

 

Low = CALCULATE(SUM('Table1'[Sale]), FILTER('Table1', 'Table1'[Fruit] = SELECTEDVALUE('Table1'[Fruit]) && 'Table1'[Sale] < 10 ))
Medium = CALCULATE(SUM('Table1'[Sale]), FILTER('Table1', 'Table1'[Fruit] = SELECTEDVALUE('Table1'[Fruit]) && 'Table1'[Sale] >= 10 && 'Table1'[Sale] < 20 ))
Max = CALCULATE(SUM('Table1'[Sale]), FILTER('Table1', 'Table1'[Fruit] = SELECTEDVALUE('Table1'[Fruit]) && 'Table1'[Sale] >= 20 ))

 

 

 

Add these to a Table visual

frtab.png

If you add more fruit the measures will work for them

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


amitchandak
Super User
Super User

@ktt777 , Create a new column like the below in you table and use in as column in Matrix

 

If([Fruit] ="Apple",
Switch ( True(),
[Sale] <=10 , "Low",
[Sales] <=20, "Medium",
"Max"
),
Switch ( True(),
[Sale] <=15 , "Low",
[Sales] <=25, "Medium",
"Max"
)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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