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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AndreaLorenzo
Frequent Visitor

Using TREATAS for different granularity levels

Hi,

I'm struggling with a common problem (two tables with different granularity) and I hope someone could help me.

I need to comparte the actual sales pending invoice amount with the budgeted one, but the sales fact table is way more detailed than the budget one.


In my model, I've got:

 1) Sales fact fable, with columns   Year, Month, Week, Customer_Id, Area_Id, Pending_Sales_Amount

 2) Goals table, with columns   Year, Id_Area, Pending_Goal

 

I've been re searching and I know I can use TREATAS, but I'm not able to build the correct DAX expression.

 

Any help would be appreciated, thanks

 

 

 

3 REPLIES 3
Anonymous
Not applicable

Hi @AndreaLorenzo ,

 

Please try this:

Sales_vs_Goals = 
CALCULATE(
    SUM(Sales[Pending_Sales_Amount]),
    TREATAS(
        SUMMARIZE(ALLSELECTED(Goals), Goals[Year], Goals[Id_Area], "Pending_Goal", SUM(Goals[Pending_Goal])),
        Sales[Year],
        Sales[Area_Id]
    )
)

 

Best Regards,

Neeko Tang

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

Joe_Barry
Super User
Super User

Hi @AndreaLorenzo 

 

If you want to visualise the comparisons on a line graph for example with Month in the x Axis, then your Budget table will need to be broken down into months.

 

In Power Query you can do the following in your Goals Table for a monthly overview. 

 

Create a custom column to get a monthly amount

[Pending_Goal] / 12

Create another column called DateKey and Enter

"01/01/" & [Year]

convert to Date

 

Create a custom column called intervals with this formula

List.Numbers(1,12)

Expand the column

 

Now we need to create a date column for each interval called Month

Date.StartOfMonth(
  Date.AddMonths(
    [DateKey],
    [Intervals] -1
  )
))

Convert to date

 

You will have a monthly amount for each month of the year

 

Load the table and create a one to many relationship from the date table to the Month column in Goal table

 

Create a measure to  calculate the Goal amount 

Pending Goal = SUM('Goals'[MonthlyAmount]

Create a similar Measure from your Sales table and add the Dates from your date table to a visual and then the two measures and you will then get a comparison.

 

These measures will be the basis of all your measures.

 

Thanks

Joe

 

If you found my answer helpful and it solved your issue, please accept as solution




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


Hi @Joe_Barry ,

 

Thanks for the idea. Unfortunately, I can not split the goal into 12 months as it doesn't make sense in my scenario.

 

I will have to keep on investigating.

 

Thanks

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors