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

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.

Reply
anna-lee
Helper I
Helper I

help with conditional statement

Hello,

Currently having difficultly finding a way to create a conditional measure based off the sum of the previous year. I currently have two measures in place posted below iwth the data set. I'd like to get a conditional statement to give  : If sum of previous year of 'Total Value' > 0, then 'Receivables Turnover', else 0

Total Value = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Vendor Code],'Table'[Year]))

Receivables Turnover =
  VAR Year = MAX('Table'[Year])
  VAR Rev = SUMX(FILTER('Table',[Description] = "revenue" && 'Table'[Vendor Code] = SELECTEDVALUE('Table'[Vendor Code])),[Value])
  VAR AR = SUMX(FILTER('Table',[Description] = "accountsreceivable" && 'Table'[Vendor Code] = SELECTEDVALUE('Table'[Vendor Code])),[Value])
  VAR ARPY = SUMX(FILTER(ALL('Table'),[Description] = "accountsreceivable" && [Year] = Year - 1 && 'Table'[Vendor Code] = SELECTEDVALUE('Table'[Vendor Code])),[Value])
  VAR RT = DIVIDE(Rev, (AR + ARPY) / 2)
RETURN
    RT
 
Vendor CodeDescriptionConcatYearValueResult
MA33C4accountsreceivableMA33C4accountsreceivable2021177414194
MA33C4accountsreceivableMA33C4accountsreceivable2020150113904
MA33C4accountsreceivableMA33C4accountsreceivable2019110310484
MA33C4accountsreceivableMA33C4accountsreceivable2018461520214
MA33C4accountsreceivableMA33C4accountsreceivable2017685220017
MA33C4accountsreceivableMA33C4accountsreceivable2016182710004
MA33C4accountspayableMA33C4accountspayable2021109414194
MA33C4accountspayableMA33C4accountspayable2020169713904
MA33C4accountspayableMA33C4accountspayable2019214410484
MA33C4accountspayableMA33C4accountspayable2018349820214
MA33C4accountspayableMA33C4accountspayable2017362420017
MA33C4accountspayableMA33C4accountspayable2016110910004
MA33C4revenueMA33C4revenue2021148014194
MA33C4revenueMA33C4revenue2020150213904
MA33C4revenueMA33C4revenue2019100210484
MA33C4revenueMA33C4revenue2018762420214
MA33C4revenueMA33C4revenue2017548920017
MA33C4revenueMA33C4revenue2016485010004
MA33C4costofgoodsMA33C4costofgoods2021984614194
MA33C4costofgoodsMA33C4costofgoods2020920413904
MA33C4costofgoodsMA33C4costofgoods2019623510484
MA33C4costofgoodsMA33C4costofgoods2018447720214
MA33C4costofgoodsMA33C4costofgoods2017405220017
MA33C4costofgoodsMA33C4costofgoods2016221810004
RQ020GaccountsreceivableRQ020Gaccountsreceivable202100
RQ020GaccountsreceivableRQ020Gaccountsreceivable2020100911802
RQ020GaccountsreceivableRQ020Gaccountsreceivable2019190312597
RQ020GaccountsreceivableRQ020Gaccountsreceivable2018156611546
RQ020GaccountsreceivableRQ020Gaccountsreceivable2017108313891
RQ020GaccountsreceivableRQ020Gaccountsreceivable201600
RQ020GaccountspayableRQ020Gaccountspayable202100
RQ020GaccountspayableRQ020Gaccountspayable2020430711802
RQ020GaccountspayableRQ020Gaccountspayable2019274312597
RQ020GaccountspayableRQ020Gaccountspayable2018227211546
RQ020GaccountspayableRQ020Gaccountspayable2017239713891
RQ020GaccountspayableRQ020Gaccountspayable201600
RQ020GrevenueRQ020Grevenue202100
RQ020GrevenueRQ020Grevenue2020358211802
RQ020GrevenueRQ020Grevenue2019423912597
RQ020GrevenueRQ020Grevenue2018400011546
RQ020GrevenueRQ020Grevenue2017532513891
RQ020GrevenueRQ020Grevenue201600
RQ020GcostofgoodsRQ020Gcostofgoods202100
RQ020GcostofgoodsRQ020Gcostofgoods2020290411802
RQ020GcostofgoodsRQ020Gcostofgoods2019371212597
RQ020GcostofgoodsRQ020Gcostofgoods2018370811546
RQ020GcostofgoodsRQ020Gcostofgoods2017508613891
RQ020GcostofgoodsRQ020Gcostofgoods201600
1 ACCEPTED SOLUTION
Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi @anna-lee ,

 

Create following measures:
PY Total Value= CALCULATE(Table[Total Value], PREVIOUSYEAR(Table[YEAR]))
------please make sure the YEAR column is in date format.

 

Measure= 
if(PY Total Value >0, Receivables Turnover, 0)

 

 

Mark this as a solution, if I answered your question. Kudos are always appreciated.

 

 

Thanks

View solution in original post

2 REPLIES 2
Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi @anna-lee ,

 

Create following measures:
PY Total Value= CALCULATE(Table[Total Value], PREVIOUSYEAR(Table[YEAR]))
------please make sure the YEAR column is in date format.

 

Measure= 
if(PY Total Value >0, Receivables Turnover, 0)

 

 

Mark this as a solution, if I answered your question. Kudos are always appreciated.

 

 

Thanks

@Tanushree_Kapse 
Thanks. It works in theory, but when I change my Year column to a date, it changes the output of my original 'Receivables Turnover' measure to incorrect numbers. 

I did a work around where I could keep my Year column as an integer by adding a measure:

 

Value PY =
    VAR Year = MAX('Table'[Year])
    VAR PY = Year - 1
RETURN
    CALCULATE([Total Value],'Table'[Year] = PY)

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors