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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
VDS9
Frequent Visitor

index help dax

Can I still use similar code to the below if headers are different on different sheets and also the Friday is different from other 4 days of the week in every sheet. Data is coming from an excel file with different sheets. However although headers are almost the same, the first 3 sheets have 1 less column. For example, first 3 sheets will have: MA(arrival),MR(reading),M1(lesson1),M2,MB,M3,M4,ML,M5,M6,ME,MD and the remaining sheets have MA,MR,M1,M2,M3,MB,M4,M5,ML,M6,M7,ME,MD. Also, Fridays looks differentfrom other days of the week for everyone: FA,FR,F1,F2,FB,F3,F4,FL,FF,FA,FO.

 

Trying to have a timeline with lessons and sessions in the right order.

Will I be able to still create something like this? Or due to the different headers won’t be possible?

Help appreciated. I’m stuck here.

 

Thanks,

 

= Table.AddColumn(

    #"Changed Type",

    "Lesson Index",

    each let

        Digits = {"0".."9"},

        LessonSplit = Splitter.SplitTextByCharacterTransition(each not List.Contains(Digits,_), each List.Contains(Digits,_))([Lesson]),

        DayOfWeek = try LessonSplit{0} otherwise null,

        NumberPart = try Number.From(LessonSplit{1}) otherwise null,

        DayOfWeekIndex = if DayOfWeek = "M" then 0

                         else if DayOfWeek = "T" then 1

                         else if DayOfWeek = "W" then 2

                         else if DayOfWeek = "TH" then 4

                         else if DayOfWeek = "F" then 5

                         else null,

        // Handle non-numbered slots

        SlotIndex = if NumberPart = null then

                        if [Lesson] = "MA" then 10

                        else if [Lesson] = "MB" then 20

                        else if [Lesson] = "ML" then 30

                        else if [Lesson] = "TA" then 110

                        else if [Lesson] = "TB" then 120

                        else null

                    else

                        DayOfWeekIndex * 100 + NumberPart

    in

        SlotIndex

)

5 REPLIES 5
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

VDS9
Frequent Visitor

How can I send a sample without the column "name"? Thats the only column with sensitive information

Remove that column before posting the data. 

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

 

VDS9
Frequent Visitor

You need the data sheet where the data is or the pbix file? Because I have several other sensitive data on linked to the pbix. I will send you the excel

Hi @VDS9 ,

You can provide some raw data in your tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples just as suggested by Ibendlin. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Helpful resources

Announcements