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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kirah2128
Helper I
Helper I

Filter Context Calculations

Dear All,

 

I'm still learning the DAX language. And I'm having a hard time. 

 

I have a scenario where I need to get the correct COMPONENT HOURS. The result I want is in the Car Filter Context but if I change it to YEAR MONTH Filter context it gives me different value. . I'll show in below table. 

 

Total COMPONENT HRS = 278896 - The correct One.

What I mean is the sum of the first table when calculated manually. Not the actual results in Powerbi. Both totals either CAR Filter Context or YEAR MONTH context provide wrong output in my powerbi. 

CARSUS REMOVALHOURSQPA FINAL 2COMPONENT HRS
A12451929039
A22401328026
A33483929679
A42465429309
A52461929237
A60471829437
A71478129561
A81477929558
A91470829416
A101459229183
A111479729594
A120467929358
A131453429068
A141449928997
A151459129181
A161490129801
A171461529230
A181459429188
A192463329266
A200417128342
A212494429889
A223470829416
A230495329906
A241485829716
A250496029921
A261429528591
A270466300
A280466600
A290444800
A300468000
A310471400
A320470900
A330463300
A340479300
A350463700
A360180700
A370444828896
A382457529150
A390456929138
A400455229104
A4101432286
A420922184
A4301142229

 

Below table shows the wrong values. 
I get a total of which is wrong.

366393
YearMonthUS12MonthsFH12MonthsQPA FINALCOMPONENT HRS
2023-0341170168229137
2023-0440170685229526
2023-0537171883231492
2023-0638172874229659
2023-0742173659230337
2023-0841174344229993
2023-0942175523228984
2023-1034177035231274
2023-1133178162230088
2023-1232179160231974
2024-0131180845232898
2024-0233183196231031

 

What I understand is in the first table above where there are red fonts. Its still included in the calculations when changed to Year Month Filter Context. Is there a way not to include them? I tried all the options such as adding IF(ISBLANK()) but its not working.

 

3 REPLIES 3
QuentinBl
Helper I
Helper I

You should try a SUMX in your measure. Right now, your measure total is the total of car usage (183196) * total of QTY per usage (2) which is wrong for you. 
You want to do the multiplaction for each row and then sum all the results. 

Try something like SUMX('CARS MODEL', [CARS USAGE]  * [QTY PER CAR])

 



QuentinBl
Helper I
Helper I

Hello, i'm sorry but your explanation is not clear. I understand that the total is wrong is your table but that you calculated it yourself in the source. 
Can you show us the measure if you have one, the total given by Power BI in the bottom of your table and the model with the relationships if there is more than one table involved ?

If in power bi, you put the SUM of component hours without axes, it shows you the correct answer ? if yes, the result shouldn't change when you add axes. if no, the problem is maybe in power query or in the query you use in your source.

 

 

 

kirah2128_4-1711164279794.png

 

 

CARS USAGE = SUM('CARS UTILIZATION'[cars_utilziation_in_mins])/60
QTY PER CAR = COALESCE(MAX('QTY COMP PER CAR'[qpa]),0)
COMPONENT HRS = [CARS USAGE] * [QTY PER CAR]
 
kirah2128_3-1711164033990.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors