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
saqib1
Helper II
Helper II

Will identical Batch numbers in different Business units be an issue in data modelling/DAX?

Hi,

 

A certain industry has different business units (BU) manufacturing similar products. It wants to track and compare the performance of different batches within and among the BUs (intra and inter BU).

The BU Id and the Batch Id columns are numerically numbered from 1,2,3...onwards. But due to some user friendliness issue, the dashboard needs to be such that the Batch Number/Name column also needs to be numerical such that within each BU, the first batch of the year would be numbered 1 then 2 & so on. 

Business Unit IdBatch IdBatch Number
111
122
133
241
252
263
371
382

The problem is that this way each BU will have identical Batch numbers. Should this be a cause of concern in data modelling/DAX? If yes, then what could be the solution (considering that Batch numbers HAVE to start from 1 for each BU at year start).

 

Appreciate your time.

2 ACCEPTED SOLUTIONS
grazitti_sapna
Resolver I
Resolver I

Hi @saqib1 

You can create a calculated column named "Year" to extract the year from the "Batch Date" column: 

Year = YEAR('YourTable'[Batch Date])

 

 

Create a calculated column named "Batch Number" using the following formula:

Batch Number =
RANKX(
FILTER(
ALL('YourTable'),
'YourTable'[Business Unit Id] = EARLIER('YourTable'[Business Unit Id]) &&
YEAR('YourTable'[Batch Date]) = EARLIER('YourTable'[Year])
),
'YourTable'[Batch Id],
,
ASC,
Dense
)

 

This way you will achieve you desired output

Hope this will help.

View solution in original post

Hi, @saqib1 

I think the @grazitti_sapna answer is right ,it just  group and sort according to the year and BU id, if you just want to group according to the BU id, you can remove the judgment of the year.

Batch Number = RANKX(
FILTER(
ALL('Batching Detail'),
'Batching Detail'[BU Id]= EARLIER('Batching Detail'[BU Id])
),
'Batching Detail'[Batch Id],
,
ASC,
Dense
)

vyueyunzhmsft_0-1686622934399.png

 

And for your date format , you can use "Using Local":

vyueyunzhmsft_1-1686623381759.pngvyueyunzhmsft_2-1686623402325.pngvyueyunzhmsft_3-1686623409186.png

Also you can use format to convert, for this you can refer to :
Solved: How to configure power query date as dd/mm/yyyy in... - Power Platform Community (microsoft....

excel - Power BI: Convert text (yyyymmdd) to date (dd/mm/yyyy) - Stack Overflow

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

View solution in original post

4 REPLIES 4
grazitti_sapna
Resolver I
Resolver I

Hi @saqib1 

You can create a calculated column named "Year" to extract the year from the "Batch Date" column: 

Year = YEAR('YourTable'[Batch Date])

 

 

Create a calculated column named "Batch Number" using the following formula:

Batch Number =
RANKX(
FILTER(
ALL('YourTable'),
'YourTable'[Business Unit Id] = EARLIER('YourTable'[Business Unit Id]) &&
YEAR('YourTable'[Batch Date]) = EARLIER('YourTable'[Year])
),
'YourTable'[Batch Id],
,
ASC,
Dense
)

 

This way you will achieve you desired output

Hope this will help.

Hi @grazitti_sapna Thanks alot for giving your time.

 

Apologies for late reply, actually the solution provided is not giving the intended results. I was working on the data from few days to see whether there's a mistake from my side. Kindly see below the link of the pbix file.

 

https://1drv.ms/u/s!AoqwAyWfotQsjQgSbAyaW1EDLYEe?e=0ns1yU 

 

The BU Id 1 is giving correct result for the batch numbers but BU Ids 2 & 3 are giving incorrect results. I have also given name to BUs. The user should be able to select the BU name and Batch number and consequently able to fetch the data of the respective BU's specific batch Number.

 

One more thing, if it's in your domain or have knowledge about it, I want the batch dates in UK Date format i.e. DD/MM/YYY. I entered all dates in this format in Excel but the ones starting from Single digit dates i.e. 01-09 always reverse the format in Power BI i.e. 01 July 2022 becomes 07 January 2022 and similarly other such dates. I have tried Using Locale to set date formt to UK but it's also not woring. Can you kindly guide on this also? Maybe this could have had an impact on the BU Ids 2 & 3?

 

Thanks again for your time 🙂

Really appreciate it

Hi, @saqib1 

I think the @grazitti_sapna answer is right ,it just  group and sort according to the year and BU id, if you just want to group according to the BU id, you can remove the judgment of the year.

Batch Number = RANKX(
FILTER(
ALL('Batching Detail'),
'Batching Detail'[BU Id]= EARLIER('Batching Detail'[BU Id])
),
'Batching Detail'[Batch Id],
,
ASC,
Dense
)

vyueyunzhmsft_0-1686622934399.png

 

And for your date format , you can use "Using Local":

vyueyunzhmsft_1-1686623381759.pngvyueyunzhmsft_2-1686623402325.pngvyueyunzhmsft_3-1686623409186.png

Also you can use format to convert, for this you can refer to :
Solved: How to configure power query date as dd/mm/yyyy in... - Power Platform Community (microsoft....

excel - Power BI: Convert text (yyyymmdd) to date (dd/mm/yyyy) - Stack Overflow

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Thanks alot @v-yueyunzh-msft Yes that's correct. I couldn't understand it earlier. btw can the YEAR function fetch data according to Financial Year also (1st Jul- 30th Jun)? If Yes, can you kindly guide how?

 

The Date format is also correct now. Although I was previously also doing the same thing 🙂 

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.