functions
5 TopicsHow to use Table-Valued Functions in MS Report Builder
I have a Table-Valued Function in SQL that I'm trying to pull into MS Report Builder. It has 4 parameters (Start Date, Version ID 1, End Date, Version ID 2). My Function is: [dbo].[RateAttributionReportNmd] (@StartTapeDate DATE, @StartVersionId INT, @EndTapeDate DATE, @EndVersionId int) However, those 4 parameters aren't actual fields in the data but I want to use them as parameters in the report so that the function parameters can be used to update the data/SQL query. SELECT * FROM [dbo].[RateAttributionReportNmd] ('2024-10-31', 3, '2024-11-30', 2)Solved1.4KViews0likes2CommentsDAX macro / dynamically switch table to be used in measures
Hi, I am trying to dynamically switch the tables used for specific DAX measures. Ex: I want to know number of rows and sum of a specific column for every table I have imported (assuming each table has the same column to sum) Let's say I have 3 tables so far... Table1 Table2 Table3 Let's say I have two measure... NumberOfRows ColumnSum Let's say I have a created table that lists the tables... TableID Table Name 1 Table2 2 Table2 3 Table3 WHAT I CURRENTLY HAVE: The measures look like this... NumberOfRows = SWITCH(Table[ID], 1, COUNTROWS(Table1), 2, COUNTROWS(Table2), 3, COUNTROWS(Table3)) ColumnSum = SWITCH(Table[ID], 1, SUM(Table1[Column]), 2, SUM(Table2[Column]), 3, SUM(Table3[Column])) Currently, if I add new tables to my report, I add the new table expression to each measure! WHAT I WANT: To only have to update one DAX measure and all the other measure update as well. EX: having a dax measure called "TableUsed" and all my measures use that table TableUsed = SWITCH(1, Table1, 2, Table2, 3, Table3) NumberOfRows = COUNTROWS(TableUsed) ColumnSum = SUM(TableUsed) This way when I add new tables, all I have to update is the TableUsed measure, and not every single measure it uses. Right now I don't know how to havea table be the return value of a measure or how to create any sort of macros / functions for DAX formulas to dynamically change the "text" used in the DAX. If anyone knows any solution or has any input... Please provide! Thank you.1.6KViews0likes4CommentsData puzzle with great value!
Hello! I am new to Power BI and trying to do somethign quite complicated - or so I believe. I have two columns, one with let's say 'numbers X'. I have another column with let's say 'numbers Y'. I would like to return all X values with the same Y value for selected values in column 'numbers X', but not returning a repeat within a selected value from 'numbers X'. The issue I am running into is the lookup function is returning a repeat selected value for itself. See example below. '1' and '2' would be returned because it was found with same 'numbers Y'. '4' would not be returned because 'numbers Y' did not have a repeat value outside of itself. numbers X numbers Y Selected Values (drop down of 'numbers X') Results ('numbers X' with same values in 'numbers Y') 1 10 1 1 1 12 2 2 1 10 4 2 10 2 15 2 13 3 10 3 9 3 6 4 7 4 27 4 9 4 7Solved1KViews0likes2CommentsDATEADD doesn't work with cumulative sum
Hello. I've got the next problem - i want to calculate WoW, and because there isn't any function i use DATEADD function to calculate values a week ago. But there is a problem i can't solve - it doesn't work with cumulative values (i guess it's the reason of problem). There are 4 measures (for convenience i put them together, also don't mind error lines - i just translated names to English, first 3 work totally fine) - the first one to sum working hours, the second one to gain cumulative sum, the third one to substract cumulative sum from a digit (20), and the forth one should show data a week ago. But it doesn't work properly. For convenience i used 0 interval in DATEADD - the data should be as in the third column, but for some reason it substracts the first column and not the second one as it should be. I'll be very glad if you'll help me to solve this problem (or will give another solution). Have a nice day anyway.Solved1.4KViews0likes3CommentsUsing a function returns blank when using another function value
Hi, I was wondering if anyone could help - new to the community. I have some DAX code that should return some student attendance for the previous week. However, I currently have to hard code the previous fiscal week number, when I place the value from the Calendar Dates table (Calculates the previous fiscal week from the current). This my code Previous Week Attendance Measure = var _measure = DIVIDE( CALCULATE( COUNT('AT_Session_Marks'[Session Mark]), FILTER(AT_Session_Marks, 'AT_Session_Marks'[Absent] = TRUE), FILTER('AT_Session_Marks', 'AT_Session_Marks'[Fiscal Week No] = 1) ), CALCULATE( COUNT('AT_Session_Marks'[Session Mark]), FILTER('AT_Session_Marks', 'AT_Session_Marks'[Fiscal Week No] = 1) ), 0) return IF(ISBLANK(_measure), 0, _measure) The above returns the correct amount. Previous Week Attendance Measure = var _measure = DIVIDE( CALCULATE( COUNT('AT_Session_Marks'[Session Mark]), FILTER(AT_Session_Marks, 'AT_Session_Marks'[Absent] = TRUE), FILTER('AT_Session_Marks', 'AT_Session_Marks'[Fiscal Week No] = 'Calendar Functions'[Previous Fiscal Week]) ), CALCULATE( COUNT('AT_Session_Marks'[Session Mark]), FILTER('AT_Session_Marks', 'AT_Session_Marks'[Fiscal Week No] = 'Calendar Functions'[Previous Fiscal Week]) ), 0) return IF(ISBLANK(_measure), 0, _measure) Whereas the above returns 0 despite the 'Calendar Functions'[Previous Fiscal Week] outputting the correct value. Appreciate some guidance. TIASolved615Views0likes1Comment