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
samue_an
Helper I
Helper I

DAX subtracting a variable - as basic as that but not working for me ???

Hi Guys, pulling my hair out with this basic DAX - just returning -1, no clue why returning all variables correctly but when doing the last basic arithmetic it does not like it???? Please can you spot what I'm doing wrong, TIA
 
 
WC Total Traffic Vol Increase =
VAR DateRef =
DATE ( "2020", "3", "13" ) // This is my reference date
VAR Territory = "WC" // Reference territory
// Finding the total carried Data Volume for all techs on my reference date
VAR Total_data_vol_ref_day =
CALCULATE (
SUM ( WFH_DATA_TRENDS[Total Data Volume in TB] ),
'WFH_DATA_TRENDS'[Time]= DateRef,
WFH_DATA_TRENDS[Territory] = "WC"
)
// Returning the rows of total data volume/data volume from reference day
VAR result =
CALCULATE (
SUM(WFH_DATA_TRENDS[Total Data Volume in TB]),
WFH_DATA_TRENDS, WFH_DATA_TRENDS[Territory] = "WC"
) --VAR result = DIVIDE(tottraffvolin_tb,Total_data_vol_ref_day)
RETURN
DIVIDE(result-Total_data_vol_ref_day,
Total_data_vol_ref_day)
3 REPLIES 3
Fowmy
Super User
Super User

@samue_an 

Check the modified formula below. Also, have a look at the final line, could be 

DIVIDE(result-Total_data_vol_ref_day, result)



WC Total Traffic Vol Increase =
VAR DateRef =
    DATE ( 2020, 3, 13 )
VAR Territory = "WC"
VAR Total_data_vol_ref_day =
    CALCULATE (
        SUM ( WFH_DATA_TRENDS[Total Data Volume in TB] ),
        'WFH_DATA_TRENDS'[Time] = DateRef,
        WFH_DATA_TRENDS[Territory] = Territory
    )
VAR result =
    CALCULATE (
        SUM ( WFH_DATA_TRENDS[Total Data Volume in TB] ),
        WFH_DATA_TRENDS[Territory] = "WC"
    )
RETURN
    DIVIDE ( result - Total_data_vol_ref_day, Total_data_vol_ref_day )

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

HashamNiaz
Solution Sage
Solution Sage

Hi @samue_an !

Does all the participating variable in Final DIVIDE() expression are of Numeric data type INT/DECIMAL.

 

Also can you post some sample data. Also try to to wrap your WFH_DATA_TRENDS, WFH_DATA_TRENDS[Territory] = "WC" expression sinside FILTER() liek below;

VAR result =
CALCULATE (
SUM(WFH_DATA_TRENDS[Total Data Volume in TB]), 
FILTER(WFH_DATA_TRENDS, WFH_DATA_TRENDS[Territory] = "WC")
)

 

See if this solves your issue. Also can you put a Date Slicer only to pick selected date. Seems like you have't connected your Fact table with Calendar / Date Dimension.

 

Regards,

Hasham

 

samue_an
Helper I
Helper I

If I just return all the variables individually they return the correct values, but when I want to subtract the Total_data_vol_ref_day variable highlighted below:

DIVIDE(result-Total_data_vol_ref_day,
Total_data_vol_ref_day)
 
So basically only 2 calculations finding variables and at the end apply subtraction and division ???

 

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.