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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tomfiki
Frequent Visitor

Measure with values matching another table (no relationships)

Hello all,

Could you please help me get this DAX formula working?

ShipTest2 = CALCULATE([Shipments],FILTER(MTH_Table,MTH_Table[MTH]=VALUES(DATES[Month])))

I need to have the result in the first matrix the same as in the second matrix. I was not able to figure out how to separate the numbers for the first table into months - the column MTH in MTH_table has no relationship with Month in DATES table.

 

The only way I was able to get this "working" was to create 12 separate measures for each month which is not very efficient, I'd say.

Tomfiki_0-1637849121520.png

 

Please don't get into why I ask this stupid question. 😄 I need to further include in the calculation another measure with another date table.
I apologize if the solution is already here somewhere, I was not able to find it.

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Tomfiki  can you please try this

ShipTest2 = CALCULATE([Shipments], TREATAS(VALUES(MTH_Table[MTH_Table]),DATES[Month]))
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

4 REPLIES 4
smpa01
Super User
Super User

@Tomfiki  have a read of this https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/

 

If there is no relationship, you can use TREATAS/CONTAINS/INTERSECT

The basic way TREATAS works as 

CALCULATE(<targetMeasure>,TREATAS(VALUES/SUMMARZE(<lookupColumn>),<targetColumn>))

Translating the above

| XAxis          | Measure                                             |
|----------------|-----------------------------------------------------|
| Axis from tbl1 | CALCULATE(<AggregateonDATES[value]>,                |
|                | TREATAS(VALUES/SUMMARZE(<MTH[MTH]>),<Dates[Date]>)) |
| Axis from tbl2 | CALCULATE(<AggregateonMTH[value]>,                  |
|                |  TREATAS(VALUES/SUMMARZE(<Dates[Date]>),<MTH[MTH]>))|
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Ok, perfect. Thanks again and have a nice evening. 🙂

smpa01
Super User
Super User

@Tomfiki  can you please try this

ShipTest2 = CALCULATE([Shipments], TREATAS(VALUES(MTH_Table[MTH_Table]),DATES[Month]))
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01 Thank you for the reply, it works great!

Could you advise how to adjust it so if I filter something in DATES[Month] it will also reflect in the result?

Tomfiki_0-1637851279866.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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