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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Rdata
Advocate I
Advocate I

Table Visual and Measure Breaks when Adding Another Column

I don't know how else to title this problem, but this is the best I've got. 

 

I have a dataset as follows, where I have Locations (TRT_ID) that could have one of two Metrics (Metric_Type), which has monthly data (Use). 

 

TRT_IDMetric_TypeDateUseCompleted
19Electricity2022/1/18566Yes
19Electricity2022/2/18052Yes
19Electricity2022/3/19334Yes
19Electricity2022/4/18681Yes
19Electricity2022/5/17529Yes
19Electricity2022/6/19166Yes
19Electricity2022/7/19350Yes
19Electricity2022/8/111342Yes
19Electricity2022/9/10No
19Natural Gas2022/1/1166.72Yes
19Natural Gas2022/2/1138.16Yes
19Natural Gas2022/3/1338.44Yes
19Natural Gas2022/4/147.12Yes
19Natural Gas2022/5/110Yes
19Natural Gas2022/6/10.36Yes
19Natural Gas2022/7/10.71Yes
19Natural Gas2022/8/10.36Yes
19Natural Gas2022/9/1 No
22Electricity2022/1/17405.86Yes
22Electricity2022/2/17166.25Yes
22Electricity2022/3/112397.47Yes
22Electricity2022/4/15691.83Yes
22Electricity2022/5/16619.3Yes
22Electricity2022/6/15988.94Yes
22Electricity2022/7/16640.56Yes
22Electricity2022/8/16154.99Yes
22Electricity2022/9/1 No

 

I have a second table that houses information on the location: TRT_ID, Site_Name, etc. , which has an active relationship with Table 1 through TRT_ID

 

I have created a measure that calculates the Z-Score, grouping by both TRT_ID and Metric Type (i.e. I want z-scores for Jan-Sep usage of electricity for Location 19), and my table currently looks like this. 

 

Final_Zscore = 

VAR FinalAverage = CALCULATE(

    AVERAGE ( Metrics_Outlier[Use] ),

    ALLEXCEPT ( Metrics_Outlier, Environmental_Data_Collection_Locations[Site_Name], Metrics_Outlier[TRT_ID], Metrics_Outlier[Metric_Type] )

    )

VAR FinalSTDev = CALCULATE(

    STDEVX.P( Metrics_Outlier, Metrics_Outlier[Use] ),

    ALLEXCEPT ( Metrics_Outlier, Environmental_Data_Collection_Locations[Site_Name], Metrics_Outlier[TRT_ID], Metrics_Outlier[Metric_Type] )

)

Return

 (SUM(Metrics_Outlier[Use])- FinalAverage)/FinalSTDev
Rdata_0-1665777736748.png

 

Everything is FINE, until I try to add "Month" from the date hierarchy. Then suddenly all my values start repeating and everything just breaks. 

 

Rdata_1-1665777827569.png

 

I understand that I need to somehow account for the date in the measure, but I just can't figure out what it is that needs to be changed/added to the measure for it to essentially ignore the "date" column completely, so I can just keep it in there for my user's reference. 

5 REPLIES 5
Aburar_123
Resolver IV
Resolver IV

Hi @Rdata ,

 

Please add Month column also in that AllExcept() function.

I've tried this in multiple iterations, and I keep getting repeat rows. 

 

Use data w/out average column: 

Rdata_0-1666292243229.png

 

Table when I add the average column

Rdata_1-1666292273515.png

 

Measure w/ date in AllExcept (I also tried pulling just the month from the Full Date's date hierarchy, AND having a month-only column 😞

 

Rdata_2-1666292331179.png

 

Ashish_Mathur
Super User
Super User

Hi,

Try this approach

1. Create a Calendar Table with calculated column formulas for year, Month name and Month number.

2. Sort the Month name column by the Month number.

3. Create a relationship from the Date column of Metrics_Outlier table to Date column of the Calendar Table

4. To your visual, drag Year and Month name from the Calendar Table

5. Your measures can be simplified to

Finalsum = SUM(Metrics_Outlier[Use])

FinalAverage = AVERAGE(Metrics_Outlier[Use])

FinalSTDev = STDEVX.P( Metrics_Outlier, Metrics_Outlier[Use] )

Final_Zscore = divide(([Finalsum]- [FinalAverage]),[FinalSTDev])

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lukiz84
Memorable Member
Memorable Member

what if you add the date column to your ALLEXCEPT modifier?

I get repeat rows no matter what mix of date I put into the allexcept of the measure

Use data w/out average column: 

Rdata_3-1666292502245.png

 

 

Table when I add the average column

Rdata_4-1666292502293.png

 

 

Measure w/ date in AllExcept (I also tried pulling just the month from the Full Date's date hierarchy, AND having a month-only column ) : 

 

Rdata_6-1666292502109.png

 

 

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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