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
Willborn
Advocate II
Advocate II

Difficulty with rolling data (column count)

Hi there!

 

I currently have a static solution to count the amount of orders placed for a machine within the last 4 years. For this, I extract the data of the last 4 years and count the unique Purchase Order no. on the machine serial no.  - then filter them to "1". This gives me all Machines, where we had only 1 order within the last 4 years.

 

Actually, the above solution is working when I extract the data from the 4 year periode only (manually). So I can show only 1 month.  My goal is to make this more dynamic, so I can extract all data from the past 5-6 years, and then be able to visualize the results of the whole fiscal year.

 

Guess this is possible using DAX measure - but how? I have 1 Date Table, and 1 Order Table. Each line shows the creation date of the order (i.e. 24.02.2014), the position in the order (i.e.0010), the order no. (i.e. 2301234), the machine serial (i.e. 1002). IMHO I have to group the order positions by machine serial no. in PBI Desktop, and then count the number of orders within the month selected-4 years = 1

 

Does anyone can help me with the DAX code?

 

Thx and best regards!

 

Patrick

2 REPLIES 2
v-ljerr-msft
Employee
Employee

@Willborn

 

According to your description, using DISTINCTCOUNT function to create a measure and showing the measure in the report with a Slicer of your Date should meet requirement. See my sample below.

 

I assume you have a Order table and a Date table like below.

order.PNG

date.PNG

1. Use the formula below to create a measure called OrderAmounts to count the amount of orders placed for a machine.

OrderAmounts = CALCULATE ( DISTINCTCOUNT ( 'Order'[Order NO] ) )

2. Then you should be able to show the amount of orders placed for a machine within the period you selected from the Slicer like below.

result.PNG

Regards

Greg_Deckler
Super User
Super User

Your issue sounds very similar to the one discussed here:

 

http://community.powerbi.com/t5/Desktop/Show-the-last-X-years-based-on-the-current-Selection-of-the-...

 

See if that gets you what you need. Essentially, you should be able to use COUNT or COUNTX (instead of SUM/SUMX) and change the FILTER criteria. 


@ 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...

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.