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
Anonymous
Not applicable

Make a matrix showing the difference between a value and count

Hey guys,
I am struggling with this problem.
In my dataset I have one table with the product family, date (of sale), month and code:

Family  Date  Month  Code

A      4/12/20   APR       10

B      2/12/20   FEB        20

C     3/12/20    MAR      10

...

From this table I made a matrix with Family on the rows, Month on the lines and Count of date on the values

The other table from my dataset has the forecast of sales wich contains the following columns: family, value and month
Family  Value  Month
A            12      APR
A             7        MAR
B             7         MAR
...
From this one I made another matrix showing our forecast for each family in each month.

Now, I need to build another matrix that shows my sales by family and month subtracted from the forecast, showing the difference of Forecast and Sales, but in this one I need to apply one filter (that is code=10).

I was going for a quick measure and a measure but couldn't do it properly, can anyone help me?
Thks!


1 ACCEPTED SOLUTION

@Anonymous What about a measure like:

Measure = 
  VAR __Month = MAX('Forecast'[Month])
  VAR __Family = MAX('Forecast'[Family])
  VAR __Forecast = MAX('Forecast',[Value])
  VAR __Sales = COUNTROWS(FILTER('Sales',[Month]=__Month && [Family]=__Family))
RETURN
  __Forecast - __Sales

 This makes some assumptions about your visual.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

I am trying to upload my pbi file but couldn't find the right way to do it!

@Anonymous - Seems doable but missing a value column of sales in first table? To share a PBIX, put it on OneDrive or Box or something and share a public link to it.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Actually, it is not missing anything because it doesn't matter actually the value of the sales, just the amount of sales for each family, the column "vsalue" on the second table goes for the number of sales.

Here it goes the link: https://drive.google.com/file/d/15-GewmUTetS3-klGVHzabqKl4tUkZnmt/view?usp=sharing

Hi,

That link does not work.  Show the expected result very clearly.


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

@Anonymous What about a measure like:

Measure = 
  VAR __Month = MAX('Forecast'[Month])
  VAR __Family = MAX('Forecast'[Family])
  VAR __Forecast = MAX('Forecast',[Value])
  VAR __Sales = COUNTROWS(FILTER('Sales',[Month]=__Month && [Family]=__Family))
RETURN
  __Forecast - __Sales

 This makes some assumptions about your visual.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 

Yep, that's exactly it man!
Thanks a lot for your help!

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.