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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mchilders56
Frequent Visitor

how to increase my results of an equation by 1 but only if another value is what I define

Here is my formula that I am using to calculate the Qty to order of an item from my database. I want to make it so that if the VI_PS_TKT_HIST_LIN[CAT_COD] (Category code) is equal to a specific value that it adds 1 to the over all number, otherwise it uses this base calculation.  I would have a list of values to reference for the category code as well. For example DOG FOOD, CAT FOOD, etc would be what I want to add more to the order qty

 

Qty to order 30 = IF( SIGN( ROUNDUP(CALCULATE((45*(SUM(VI_PS_TKT_HIST_LIN[QTY_SOLD])/VALUE([Days Between TKT_HIST])))-SUM(VI_IM_ITEM_WITH_INV[QTY_ON_HND])),0)) <0,0, ROUNDUP(CALCULATE((45*(SUM(VI_PS_TKT_HIST_LIN[QTY_SOLD])/VALUE([Days Between TKT_HIST])))-SUM(VI_IM_ITEM_WITH_INV[QTY_ON_HND])),0))
8 REPLIES 8
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

for my purposes lets use Brand and the category code. so anyhing that has brand ETTA or KOHA I want my column for Qty to order to increase by 1, but for the brand WHIMZEE and WELLNESS I want the original formula to display.

 

Item NumberDescriptionBrandQty SoldQty on HandDays on HandQty to order (21 days of supply)Number of Day to Sell Out
1104802294NOOTIE PROGILITY CALM BARKOHA1754417 
1543601271WHIMZ STIX SMWHIMZEE1291151630 
1543601479WHIMZ BRUSHZEES XSMWHIMZEE1054567950 
1543601571WHIMZ K9 VEGGIE SAUSAGE SMALLWHIMZEE791543570 
5008900798ETTA SAYS BEEF YUMM STICKSETTA6922580 
1543601480WHIMZ BRUSHZEES SMWHIMZEE641434090 
5008900795ETTA SAYS PORK YUMM STICKSETTA6219560 
5399400105ETTA SAYS TURKEY YUMM STICKSETTA5222770 
5699500801ETTA SAYS CHICKEN YUMM STICKSETTA5017620 
5659500565ETTA K9 PREM BUFFALO CHEW 7inETTA4910370 
7634489998WELLNESS CAT HEALTHY TKY DUC3zWELLNESS4917630 
1543601527WHIMZ BRUSHZEES MDWHIMZEE421396060 
1104802096KOHA DOG GF TURKEY 13ozKOHA354211 
1543601529WHIMZ ALLIGATOR SMWHIMZEE35814240 
1543601482WHIMZ BRUSHZEES LGWHIMZEE336330 
7634408863WELLNESS CAT CHKN&LBSTR 3ozWELLNESS31004138

@mchilders56 Use this DAX:

 

Formula = IF(TableName[Brand] in {"ETTA","KOHA"}, [Order to Qty]+1,[Order to Qty])

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

I get an error for the tableName[Brand] that column cannot be found or used in this expression. I am doing a direct query so the table and column are already defined for me. I think i needs to be a different format but not sure what yet in order to accept that column. I thought maybe value() but that did not work either.

 

 

 I am doing a direct query

Next time please start with that piece of information. 

 

Did you switch to mixed mode (with local data model) or does it need to be a measure?

 

Try this calculated column:

 

Formula = [Order to Qty] + INT([Brand] in {"ETTA","KOHA"})

it's only letting me select things that are measure that I have created. It's not a calculated column that I have made or anything like that. that column in my DB basically has a list of names that I can trying to reference.

Thanks for the reply from lbendlin and Tahreem24,please allow me to provide another insight:

Hi, @mchilders56 

Could you please let us know if lbendlin's response resolved your issue? If it did, kindly accept it as the solution.

vlinyulumsft_0-1734324470337.png

1.To facilitate your understanding, I have created the following test data with a storage mode set to DirectQuery:

vlinyulumsft_1-1734324470338.png

2.Secondly, I implemented ll's response:

vlinyulumsft_2-1734324528116.png

Measure = sumx('Inventory',[QtyToOrder]+INT([Brand] in {"ETTA","KOHA"}))

Of course, you can also try the following measure:

Measure 2 = IF(MAX('Inventory'[Brand]) IN {"ETTA","KOHA"},SUM('Inventory'[QtyToOrder])+1,SUM('Inventory'[QtyToOrder]))

3.Below is the final result:

vlinyulumsft_3-1734324586028.png

 

Best Regards,

Leroy Lu

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

 

measure = sumx(Table,[Order to Qty] + INT([Brand] in {"ETTA","KOHA"}))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.