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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
BryceJones
Frequent Visitor

Output for visuals is incorrect

Hi all,

 

I'm trying to create a measure that subtracts one measure from another and have it visualized in a matrix but with no success. 

 

So far I have created a date table with this DAX code to spread evenly the output on the matrix: 

 

Date range =
var _calendar =
CALENDAR(MIN('SUMX Append'[Begin]),MAX('SUMX Append'[End]))
RETURN
SELECTCOLUMNS(FILTER(CROSSJOIN('SUMX Append',_calendar),
'SUMX Append'[Begin]<= [Date] && 'SUMX Append'[End] >= [Date]),
"ID", [ID], "Date",[Date])
 
BryceJones_6-1733762220267.png

 


 

I then created a measure that uses sumx that pulls from one table if a condition is met and another table if that condition is met:

Sumx meaure =

var _inputa = SUMX(FILTER('Features', 'Features'[Sort Order] < 123),'Features'[Output])  
var _inputb = SUMX(FILTER('Features and Stories', 'Features and Stories'[Sort Order] > 122),'Features and Stories'[Estimate])
return _inputa + _inputb
 
Which it visualizes as expected here:
BryceJones_1-1733761055952.png

 

I then created another date table with DAX code: 

 

Date = ADDCOLUMNS(  CALENDARAUTO(), "Year", YEAR([Date]), "Month", FORMAT([Date],"mmmm"),"Month Number", MONTH([Date]))
 
BryceJones_2-1733761123018.png

 

And then created a relationship based on date with another table and grabbed the column of interest which was successful 

 

BryceJones_3-1733761185585.png

 

The problem I am now running into is that I want to subtract the output of the SUMX measure from the output of the visual directly above. As can be seen, the numbers are really off. 

BryceJones_4-1733761673368.png

My initial inclination was to create an inactive relationship between the date tables then create a measure encapusltating the column in Calculate with the filtler being USERELATIONSHIP to force the inactive relationship between the two date tables and subtracting the measure with no luck.

 

I also referenced the two tables in Power Query applied the filters then appended the new tables into one Altering the SUMX measure with no luck 

BryceJones_5-1733761990551.png

Has anyone encountered something similar?

 

3 REPLIES 3
v-heq-msft
Community Support
Community Support

Hi @BryceJones ,
Based on your description, you previously created inactive relationships in two date tables and wrapped the expressions using calculate. Then you can try to encapsulate the data in sumx so that it will be calculated in context at the same time

Subtraction Measure = 
VAR _inputa = SUMX(FILTER('Table1', 'Table1'[Column1] < 123), 'Table1'[Column1])
VAR _inputb = SUMX(FILTER('Tabl2', 'Table2'[Column2] > 122), 'Table2'[Column2])
RETURN _inputa - _inputb

 

Best regards,
Albert He


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

 

 

Hi Albert,

 

Thank you. However, what I need is to subract is the SUMX measure I created from a column in a separate table. 

 

Thanks,

 

Bryce

Ritaf1983
Super User
Super User

Hi @BryceJones 

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...

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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